# Java program to find the sum of the digits of a number

By candid | ** Posted : **
Apr 8, 2016
| ** Updated : **
Dec 21, 2017

Program

public class DigitsSum

{

public static void main(String[] args)

{

int num=251025, rem = 0, sum = 0, temp;

temp = num;

while (num > 0)

{

rem = num % 10;

sum = sum + rem;

num = num / 10;

}

System.out.print("Sum of Digits of " + temp + " is " + sum);

}

}

Output

Sum of Digits of 251025 is 15

Related Post

#### Comments