Java program for sum of digits of number

Previous
Next

In this post, we will see how to find sum of digits of number in java.
You can find unit’s place digit by number%10, add it to the total and divide the number by 10 to remove the unit’s place.

Output:

Enter a Number : 5385
Sum of digits of number 5385 is 21

That’s all about Java program to add digits of number.

Previous
Next

Join Our News Letter – Stay Updated

Subscribe to Awesome Java Content.




Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog