Computer Science, asked by pleasantcookies, 9 months ago

Write a program to print sum of digits of a given number using a method, int sumDigits(int num)

Answers

Answered by neethuprakash
2

Explanation:

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

Similar questions