why nzec error coming????????????

#include<stdio.h>
#include<stdlib.h>
void main()
{int a=0,m;
scanf("%d",&m);
while(a<m)
{if(a==m)
{printf(“YES”);
exit(0);}
a=a+1;
if(a==m)
{printf(“YES”);
exit(1);}
a=a+2;
if(a==m)
{printf(“YES”);
exit(2);}
a=a+3;}
printf(“no”);
}

NZEC means Non Zero Ending Code

i.e. you have not return 0 at the end of the program.
The general format to be followed is:

  #include<stdio.h>
    //other includes
    int main()
    {
    //Your logic
    
    return 0;
    }

Note: Follow the above pattern for all further programmes.

And about your code, why are you exiting with non-zero values i didn’t got that.
I would like to add that for values 2 and 3 . It will give runtime error giving signal -1.
Since You are exiting with non-zero values.
If you are using exit() than please pass zero only.!

1 Like

Please dont put unnecessary tags.!

That downvote was for improper use of tags and not reading the FAQ : http://www.codechef.com/wiki/faq. Hopefully @tech_boy 's answer solves your doubt

Besides the code is from an ongoing contest though it will never get accepted with this logic. Look for a better algorithm.

//