You are viewing a single comment's thread. Return to all comments →
bruh i did this way after seeing people solving the problem with loops i feel dumb
int main() {
int n,a,b,c,d,e,sum; scanf("%d", &n); a=n%10; b=((n%100)-a)/10; c=((n%1000)-b)/100; d=((n%10000)-c)/1000; e=((n%100000)-d)/10000; sum=(a+b+c+d+e); 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 →
bruh i did this way after seeing people solving the problem with loops i feel dumb
include
include
include
include
int main() {
}