183. C Program to Find Sum of a Given Number.
How does this program work?
- This Program is used to find the sum of the given number.
Here is the code
int main(void)
{
int sum=0, n, r,n1;
//Sum of a number
printf("Enter number:\n");
scanf("%d", &n);
n1=n;
while(n != 0)
{
r = n%10;
sum = sum + r;
n = n/10;
}
printf("The sum of digits of %d number is:%d",n1,sum);
return 0;
}