1#include <stdio.h>
2int main()
3{
4 int n, sum = 0, r;
5
6 printf("Enter a number\n");
7
8 for (scanf("%d", &n); n != 0; n = n/10) {
9 r = n % 10;
10 sum = sum + r;
11 }
12
13 printf("Sum of digits of a number = %d\n", sum);
14
15 return 0;
16}