
/* C Program to find the sum of individual digits of given number*/
#include<stdio.h>
int main()
{
int n,r,sum=0;
printf("Enter a no:");
scanf("%d",&n);
while(n>0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("Sum is %d",sum);
return 0;
}
INPUT/OUTPUT:
Enter a no:123
Sum is 6
http://codevidyalay.blogspot.com