Sum of Digits of a Number in C

Sum of Digits of a Number in C

Here, you will get and learn the program code to find Sum of Digits of a Number in C programming. This program is briefly explain with algorithm, DFD (Data Flow Diagram), and program code.

Sum of Digits of a Number in C

 

What is digit?

Digit is a numerical symbol used in mathematics and other disciplines such as computer science. Digits are used to represent numbers, values, and other quantities in various systems of notation.

Step 1. Input number from user.

Step 2. Get the remainder, quotient of number, by dividing 10.

Step 3. Add remainder in sum variable.

Step 4. Divide the number by 10, then replace number by quotient.

Step 5. Repeat Step 2,3,4 till then number is greater then 0.

Step 6. Print value of sum as sum of digits.

DFD (Data Flow Diagram)

DFD of sum of digits

Different 3 ways to find Sum of Digits of a Number in C

Method #1. Sum of Digits in C using while loop

Method #2.  Sum of Digits in C using Functions

Method #3.  Sum of Digits in C using Recursion

Sum of Digits in C using while loop

Output

sum of digits output

 

 

 

Check out our other C programming Examples

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top