73. JAVA Program to find the Second Biggest number from the given n numbers.
How does this program work?
- This program is used to find the Second Biggest number from the given n numbers using JAVA.
Here is the code
// To find the Second biggest from the given N numbers.
import java.util.Scanner;public class Array
{
public static void main(String[] args )
{
int n, temp;
System.out.print("Enter number of elements you want in array:\n");
Scanner skill = new Scanner( System.in);
n = skill.nextInt();
int a[] = new int[n];
System.out.println("Enter all the elements:");
for (int i = 0; i < n; i++)
{
a[i] = skill.nextInt();
}
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
if (a[i] > a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.println("Second Largest Element is :"+a[n-2]);
}
}