[C] sum_numerals.c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <stdio.h>
int main() {
int number, res = 0;
scanf("%d", &number);
while(number > 0) {
int numeral = number % 10;
res += numeral;
printf("%d\n", numeral);
number /= 10;
}
printf("Result: %d", res);
return 0;
}