swethareddy18 / Design-and-analysis-algorithm

0 stars 0 forks source link

sum of the digits #39

Open swethareddy18 opened 1 year ago

swethareddy18 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); }

swethareddy18 commented 1 year ago

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