Math, asked by ugirl2873, 1 month ago

Write
number
program in java to enter
digit number
a
and add all
add all digit​

Answers

Answered by kailashabohar
1

Answer:

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);

}

}

Answered by rajensaini69
2

Answer:

java.util.Scanner;

java.util.Scanner;public class Digit_Sum

java.util.Scanner;public class Digit_Sum {

java.util.Scanner;public class Digit_Sum { public static void main(String args[])

java.util.Scanner;public class Digit_Sum { public static void main(String args[]) {

java.util.Scanner;public class Digit_Sum { public static void main(String args[]) { int m, n, sum = 0;

java.util.Scanner;public class Digit_Sum { public static void main(String args[]) { int m, n, sum = 0; Scanner s = new Scanner(System.in);

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:");

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();

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)

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) {

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;

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;

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;

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; }

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);

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); }

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); }Output:

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); }Output:$ javac Digit_Sum.java

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); }Output:$ javac Digit_Sum.java$ java Digit_Sum

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); }Output:$ javac Digit_Sum.java$ java Digit_Sum

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); }Output:$ javac Digit_Sum.java$ java Digit_Sum Enter the number:456

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); }Output:$ javac Digit_Sum.java$ java Digit_Sum Enter the number:456Sum of Digits:15

Similar questions