I have spen hours on this code figuring out what went wrong.I am not getting why this is not showing the output.
# include <stdio.h>
#include <conio.h>
int main()
{
int a,i,j,dig,sum1=0,sum2=0,k,b,c,o;
scanf("%d",&a);
for(k=0;k<a;k++) // For test cases
{
scanf("%d",&b);
scanf("%d",&c);
for(j=b;j<=c;j++) //scanning the two numbers.
{
while(j!=0)
{sum1=0;
dig=j%10;
if(dig%2==0){sum1=(sum1+(2*dig));}
else{sum1=(sum1+dig);} //finding the sum of digits.If digit is even
j=j/10; multiply it by 2 and add if it is odd simply
` } just add
o=sum1%10;
sum2=sum2+o; //finding last digit of the sum.
}
printf("%d",sum2); //printing sum2 which is sum of all the last digits
sum1=0; of sum1
}
getch();
return 0;
}