Open Mounikachenna12 opened 1 year ago
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); }
enter the number:1432 sum of the digits of given number is 10
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); }