#include<stdio.h>
void main()
{
int n,i,remainder,sum = 0;
printf("Enter an integer : \n");
scanf("%d", &n);
i = n;
while (i!= 0)
{
remainder = i % 10;
sum = sum + remainder;
i = i / 10;
}
printf("Sum of digits of %d = %d\n", n, sum);
getch();
}
ShriRam Changed status to publish July 15, 2022