Problem with the program!

Posted by hopefulLLl on Stack Overflow See other posts from Stack Overflow or by hopefulLLl
Published on 2010-04-10T22:08:42Z Indexed on 2010/04/10 22:23 UTC
Read the original article Hit count: 289

Filed under:

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!

© Stack Overflow or respective owner

Related posts about c