Computer Science, asked by Shivanidude4323, 1 year ago

Write a program to find the largest 2 numbers and the smallest 2 numbers in the given array.

Answers

Answered by Anonymous
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 Anonymous
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