You are viewing a single comment's thread. Return to all comments →
#include <stdio.h> int main() { int number = 0, resto = 0, sum = 0, new_n = 0; scanf("%d", &number); do { resto = number % 10; new_n = number / 10; number = new_n; sum = sum + resto; } while (number != 0); printf("%d", sum); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sum of Digits of a Five Digit Number
You are viewing a single comment's thread. Return to all comments →