Multiple choice

Which of the following functions is performed by the program given below? class Demo { public static void main(String args[]) { int m, n=4325; int s=0; while(n!=0) { m=n%10; s=s+m; n=n/10; } System.out.println(“…………”+s); } }

  1. Separates digits and reverses the number

  2. Reverses the number

  3. Addition of digits of the given input number

  4. All of the above

  5. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The above code fragment separates the digits and does addition of digits of the given number 4325. The output of the given program code is 14.