C Program to Find Sum of Digits of a Number

C Program to Find Sum of Digits of a Number, let’s see how can we solve this problem in C Language.

Algorithm to Calculate Sum of Digits of a Number

  • Our C program needs the number as its target. We’ll use scanf to accept it from the user, storing it in a variable named number
  • Now we have to calculate the total no of digits present in the given number
  • Extract each digit of the number by using the ‘%’ operator
  • Add the extracted digit to the variable names sum
  • Print the variable sum

C Program to Calculate Sum of Digits of a Number

Output

C Program to Calculate Sum of Digits of a Number

Happy Coding

See Also

5 thoughts on “C Program to Find Sum of Digits of a Number”

Leave a Comment