Find sum of the digit of number using c program


C program to calculate or find sum of each digits of a given number



#include<stdio.h>
int main(){
int num,sum=0,r;
printf("\nEnter a number:");
scanf("%d",&num);
while(num){
r=num%10;
num=num/10;
sum=sum+r;
}
printf("sum=%d",sum);
return 0;
}



If you have any queries in above code find sum of the digit of number using c program, please share us.

2 comments:

tabassum said...

how to solve funstion program of c

manish said...

sorry tabassum

I am not understanding your question. plz specify more.