We can ask the user to enter a number. We will use one while loop to find out each digit present in the number.

Each step of the loop will collect one digit ( right most ) by dividing the number with 10 and storing the reminder. Each time ( loop ) reminder we will add up by storing in a variable sum.

```
#include <stdio.h>
int main()
{
int n, sum = 0, remainder;
printf("Enter an integer");
scanf("%d",&n);
while(n != 0)
{
remainder = n % 10;
sum = sum + remainder;
n = n / 10;
}
printf("Sum of digits of entered number = %dn",sum);
return 0;
}
```

This article is written by **plus2net.com** team.

* indicates required

Swapping two numbers sample code
Average of two numbers as entered by user
Highest of three numbers
Finding exam Grade of mark entered using if else condition
Calculation of user entered numbers
Percentage of Mark
Division of Mark
Digits in Number
Sum of Digits
Matrix Multiplication

Post your comments , suggestion , error , requirements etc here