Computer Science, asked by dhanvanth77, 9 months ago

sum of digits program in java ​

Answers

Answered by singhamanpratap0249
10

Answer:

Java Program to Compute the Sum of Digits in a given Integer

public class Digit_Sum

int m, n, sum = 0;

Scanner s = new Scanner(System.

System. out. print("Enter the number:")

;

m = s. nextInt()

while(m > 0)

n = m % 10;

sum = sum + n;

Answered by rinkughosh9932
13

Answer:

public class Digit_Sum.

int m, n, sum = 0;

Scanner s = new Scanner(System.

System. out. print("Enter the number:");

m = s. nextInt();

while(m > 0)

n = m % 10;

sum = sum + n;

Explanation:

Hope this will help you...

Similar questions