- 1

plz explain the output

Suppose the input is 2 3 4 5 0. What is the output of the following code? import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner input = new Scanner(System.in); int number, max; number = input.nextInt(); max = number; while (number != 0) { number = input.nextInt(); if (number > max) max = number; } System.out.println("max is " + max); System.out.println("number " + number); } }

29th Nov 2021, 2:36 PM
Tabassum Tanji
1 Odpowiedź
+ 1
You can try it in playground.. It finding maximum number from input..! Where is the your difficulty to understand it?
29th Nov 2021, 3:31 PM
Jayakrishna 🇮🇳