C Program to Print Sum of All the Digits in Number.
byAjay Kadtan•
0
Program:
#include<stdio.h>
main()
{
int store,n,sum=0,x;
printf("Enter a number: ");
scanf("%d",&n);
store=n;
while(n>0)
{
x=n%10;
sum=sum+x;
n=n/10;
}
printf("The sum of all the digits in %d is %d",store,sum);
}