Computer Science, asked by grammerdesign1, 8 months ago

Write a program in Java to input any number through a function argument and print the sum of
its digits.​

Answers

Answered by pardeepsingla80
4

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 it will help you

Similar questions