Computer Science, asked by iamlegend69, 4 months ago

write a program in java to enter a number and display the sum of digits​

Answers

Answered by rashmisethi337
2

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 Anonymous
1

Explanation:

 † {\underline{\boxed{\frak{\purple{~Answer ~In ~ Short}}}}}† \:

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;

 † {\underline{\boxed{\frak{\purple{~~aanchal~~}}}}}† \:

Similar questions
Math, 10 months ago