You are viewing a single comment's thread. Return to all comments →
int main (){
int n; scanf("%d", &n); /*int d1, d2, d3, d4, d5; d1 = n%10; d2 = (n/10)%10; d3 = (n/100)%10; d4 = (n/1000)%10; d5 = (n/10000)%10; printf("%d", d1+d2+d3+d4+d5);*/ int d=0; for (int i=0; i<=5; i++){ float p = pow (10, i); int o = n/p; d += o%10; } printf ("%d", d); 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 →
int main (){
}