We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Sum of Digits of a Five Digit Number
Sum of Digits of a Five Digit Number
Sort by
recency
|
723 Discussions
|
Please Login in order to post a comment
include
int main() {
}
int main() {
}
include
int main() { int n; int a,b,c,d,e; scanf("%d", &n); //Complete the code to calculate the sum of the five digits on n. a=n%10; b=((n%100)-a)/10; c=((n%1000)-(n%100))/100; d=((n%10000)-(n%1000))/1000; e=(n-(n%10000))/10000; printf("%d",a+b+c+d+e); return 0; }
include
int main() { int n; int a,b,c,d,e; scanf("%d", &n); //Complete the code to calculate the sum of the five digits on n. a=n%10; b=((n%100)-a)/10; c=((n%1000)-(n%100))/100; d=((n%10000)-(n%1000))/1000; e=(n-(n%10000))/10000; printf("%d",a+b+c+d+e); return 0; }