NZEC.(non-zero exit code)

I wrote a program 4 adding the reverse of two no. and then reversing the result…my program is working fine with my dev c+ and turbo c++ compiler but it is giving NZEC error in spoj…
can some one explain how to remove dat error from my programme…

#include<stdio.h>
int main()
{
int a,d,b,c,t,e,f,s,x,y;
scanf("%d",&t);
while(t--){
c=0;
f=0;
y=0;
scanf("%d%d",&a,&b);
while(a>0){
d=a%10;
c=c*10+d;
a=a/10; }
while(b>0){
e=b%10;
f=f*10+e;
b=b/10;
}
s=c+f;
while(s>0){
x=s%10;
y=y*10+x;
s=s/10;}
printf("\nthe result is %d",y); }
return y;
}

You must return 0 for int main() in c,
I modified you code now it should work fine (won’t give NZEC error).

int main() {
    int a,d,b,c,t,e,f,s,x,y; 
    scanf("%d",&t);
    while(t--){
        c=0; f=0; y=0;
        scanf("%d%d",&a,&b); 
        while(a>0){ 
            d=a%10; c=c*10+d; a=a/10; 
            
        } 
        while(b>0){
            e=b%10; f=f*10+e; b=b/10; 
            
        }
        s=c+f; 
        while(s>0){
            x=s%10; y=y*10+x; s=s/10;
        } 
        printf("nthe result is %d",y);
        }
    return 0; 
}
2 Likes