Write a program to find the largest 2 numbers and the smallest 2 numbers in the given array.
Answers
Answered by
3
Answer:
Java Program to Find the Largest Two Numbers in a Given Array
public class largest_and_second.
Scanner scn = new Scanner (System.
System. out. print("Enter no. of elements you want in array:");
int n = scn. nextInt();
int array[] = new int[n];
System. out. println("Enter all the elements:");
for (int i = 0; i < array. length; i++)
array[i] = scn. nextInt();
Answered by
3
Explanation:
Answer:
Java Program to Find the Largest Two Numbers in a Given Array
public class largest_and_second.
Scanner scn = new Scanner (System.
System. out. print("Enter no. of elements you want in array:");
int n = scn. nextInt();
int array[] = new int[n];
System. out. println("Enter all the elements:");
for (int i = 0; i < array. length; i++)
array[i] = scn. nextInt();
Similar questions