diff --git a/sum-of-digits.c b/sum-of-digits.c new file mode 100644 index 0000000..c5006e8 --- /dev/null +++ b/sum-of-digits.c @@ -0,0 +1,15 @@ +#include +int main() +{ + int n, sum = 0, m; + printf("Enter a number:"); + scanf("%d", &n); + while (n > 0) + { + m = n % 10; + sum = sum + m; + n = n / 10; + } + printf("Sum is=%d", sum); + return 0; +} \ No newline at end of file