Problem with the program!
- by hopefulLLl
Can you tell me what is the problem with this function. Can you help me to find the sum of digits of a number?
#include<stdio.h>
#include<math.h>
void main()
{
int a,i=0,j=10,k,n=0,m;
scanf("%d",&a);
while((a%j!=0)&&i>=0)
{
m=pow(10,(i+1));
k=a%m;
n=(a-(k*m)-n)/(m/10)+n;
j=m*10;
i++;
}
n=n+(n/(m/10));
printf("%d",n);
}
I need to use just the while loop... or the for loop!
when i run it it shows"resumable processor fault"..help!