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