#include <stdio.h>
int main() {
int n, sum = 0, remainder;
printf("Enter an integer\n");
scanf("%d", &n);
while (n != 0) {
remainder = n % 10;
sum = sum + remainder;
n = n / 10;
}
printf("Sum of digits of entered number = %d\n", sum);
return 0;
}
/*-via Programming Hub for Android, a top rated Programming App on Google Play
https://play.google.com/store/apps/details?id=com.freeit.java*/
Sunday, August 16, 2015
Program: Add Digits of a Number
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment