Javatpoint Logo
Javatpoint Logo

Sum of Digits

To find sum of digits of a number just add all the digits.

For example,

Logic:

  • Take the number.
  • Divide the number by 10.
  • Add the remainder to a variable.
  • Repeat the process until remainder is 0.

Example:

Given program shows the sum of digits of 14597.

Output:

PHP Sum of digits 1
Next TopicEven Odd Program




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA