• Register
754 points
7 2

Introduction:
You may have heard of many programming languages ​​today but Java is the most different. It is considered difficult. Its code is considered big but according to my guess who has learned Java language.  Today we are taking 5 numbers in which we will find out which is the largest and smallest number with the help of loop.

Java code:

Declare max as Minimum and min as Maximum

int max = Integer.MIN_VALUE, min = 

Scanner sc = new Scanner(System.in);

System.out.print("Enter 5 integers: ");

for (int i = 0; i < 5; ++i) {

int num = sc.nextInt();

if (max < num)

max = num;

if (min > num)

min = num;

}

System.out.println("Highest integer is " + max);

System.out.println("Lowest integer is " + min)

 

1 Comment

Hi, Tania .. You explained very well . I think you mistaken the title of the post. ''heighest''
Waiting for your more posts..
Thank you