problem with the programme!!

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:13 UTC
Read the original article Hit count: 259

Filed under:

kindly tell me what is the pblm with this function wont it help me 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 know the parenthesis used with math.h are nt right..what else is the pblm..i need to use just while loop..or the for loop!

© Stack Overflow or respective owner

Related posts about c