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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA