runtime error

why i m getting run time error in last digit sum problem??it’s working fine on ideone.com

include<stdio.h>

int arr[]={0,1,4,3,8,5,2,7,6,9};
int d(int i)
{int sum=0;
while(i!=0)
{
sum+=arr[i%10];
i=i/10;
}
return (sum%10);
}
int c(int n)
{
if((n%10)==0)
return (45*(n/10));
else
return(c(n-1)+d(n-1));
}
void main()
{
int t,a,b,m=0;
scanf("%d",&t);
while(t–)
{
scanf("%d %d",&a,&b);
m=c(b+1)-c(a);
printf("%d\n",m);
}
}

@isha_25 you are getting NZEC runtime error… your main function should return 0;

so
instead of void main() write int main() and after last statement add return 0; … hope that helps enjoy coding :slight_smile:

1 Like

http://www.codechef.com/viewsolution/1814294

This is ur program with replacements i suggested and it worked… also if you want any information about runtime errors then http://www.codechef.com/wiki/faq go to this link…

1 Like
//