Mounikachenna12 / Design-and-Analysis-of-Algorithms

0 stars 0 forks source link

sum of the digits #39

Open Mounikachenna12 opened 1 year ago

Mounikachenna12 commented 1 year ago

include

int main() { int n,rem,sum=0; printf("enter the number:"); scanf("%d",&n); while(n>0) { rem=n%10; sum=sum+rem; n=n/10; } printf("sum of the digits of given number is %d",sum); }

Mounikachenna12 commented 1 year ago

enter the number:1432 sum of the digits of given number is 10