C program to Calculate sum of digits of given Number
Description :
This program accepts one Integer from user and calculates the Sum of the individual digits of given number.
Ex: if the number is 1234 then sum of digits is 1+2+3+4 that is 10.
Program :

#include<stdio.h>

int main()

{

int num,sum,remainder,temp;

printf(“Enter any Number : “);

scanf(“%d”,&num);


temp = num;

sum = 0;


while(num > 0)

{

remainder = num % 10;

sum = sum + remainder;

num = num / 10;

}

printf(“Sum of the Digits of Number %d is : %d n“,temp, sum);

return 0;

}