/* Sum of digits : Sum of each digits of a number. */
#include <stdio.h>
int main()
{
int num, temp, sum = 0;
printf("Enter a number whose digits sum is to be found: ");
scanf("%d", &num);
temp = num;
while(num > 0){
sum += num%10;
num /= 10;
}
printf("Sum of digits of %d = %d.", temp, sum);
return 0;
}
Comments
Post a Comment