I realized that my code was not there. I’m sorry for the inconvenience. Now I’ve edited my question. Can you please look into my code and suggest what’s giving wrong answer.
Well you have put the whole output statements under a single if(Num>1) so if Num<=1 your program won’t output anything. Anyways it’ll be better if you posted the question also.
I feel this should run now.
int main(void) {
int t, num;
scanf("%d", &t);
while(t--)
{
int counter = 0;
scanf("%d", &num);
if(num > 1)
{
for(int i = 2 ; i <= num/2 ; i++)
{
if(num % i == 0)
{
counter = 1;
}
}
}
if(counter == 1) printf("no\n");
else printf("yes\n");
}
return 0;
}
I tried that, but still, it gave me the wrong answer. I added separately if block for checking primality of num <= 1 as shown below, but wrong answer again popped up.
Thank you all for helping me. I simply had to put a line break after printing “no” for num <= 1. I’ll take care of these silly errors next time. Thanks for your precious time