Computer Science, asked by hishamsarjun, 7 months ago

write a program to.find the sum.of three integers by reading value for user in java

Answers

Answered by anushadaram
0

Explanation:

import java.util.Scanner;

public class Digit_Sum

{

public static void main(String args[])

{

int m, n, sum = 0;

Scanner s = new Scanner(System.in);

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

m = s.nextInt();

while(m > 0)

{

n = m % 10;

sum = sum + n;

m = m / 10;

}

System.out.println("Sum of Digits:"+sum);

}

}

Similar questions