What is wrong in my code for Double String ?

This is the code I had submitted :-

#include <stdio.h>
int main ()
{	int t,j;
	scanf ("%d", &t);
	
	for (j=1;j<=t;j++)
	{	int n;
		scanf ("%d",&n);
		if (n%2==0)
		printf ("%d",n);
		
		else
		printf ("%d",n-1);
	}
	return 0;
}

Can anyone explain why it is wrong ?

You have to print result in new line,i.e add “\n” after each output.

printf ("%d\n",n);

And

printf ("%d\n",n-1);

You’ll get AC!!:slight_smile:

1 Like