Question1: WRITE A JAVA PROGRAM TO CREATE AN ARRAY OF INTEGER TYPE AND FIND THE BIGGEST AND THE SMALLEST ELENTS IN THE GIVEN ARRAY.
PROGRAM LOGIC: CREATED ARRAYS IN ASCENDING ORDER USING BUBBLE SORT AND THEN FINDING THE NUMBERS AT THE LOWEST POSITION AND AT BIGGEST POSITION
import java.io.*;
class array_bubble_sort
{
public static void bubble_sort() throws IOException
{
int y[]=new int[5];
int temp;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
for (int m=0;m<y.length;m++)
{
System.out.println("enter"+(m+1)+"value");
y[m]=Integer.parseInt(br.readLine());
}
for(int i=0;i<y.length;i++)
{
for(int k=0;k< y.length-1;k++)
{
if(y[k]>y[k+1])
{
temp=y[k];
y[k]=y[k+1];
y[k+1]=temp;
}
}
}
for(int i=0;i<y.length;i++)
{
System.out.print(y[i]+" ");
}
System.out.println("the smallest no. is"+y[0]);
System.out.println("the biggest no. is"+y[y.length-1]);
}
}
IF YOU HAVE ANY COMPLIMENTS OR ANY DOUBT EMAIL OR COMMENT BELOW
PROGRAM LOGIC: CREATED ARRAYS IN ASCENDING ORDER USING BUBBLE SORT AND THEN FINDING THE NUMBERS AT THE LOWEST POSITION AND AT BIGGEST POSITION
import java.io.*;
class array_bubble_sort
{
public static void bubble_sort() throws IOException
{
int y[]=new int[5];
int temp;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
for (int m=0;m<y.length;m++)
{
System.out.println("enter"+(m+1)+"value");
y[m]=Integer.parseInt(br.readLine());
}
for(int i=0;i<y.length;i++)
{
for(int k=0;k< y.length-1;k++)
{
if(y[k]>y[k+1])
{
temp=y[k];
y[k]=y[k+1];
y[k+1]=temp;
}
}
}
for(int i=0;i<y.length;i++)
{
System.out.print(y[i]+" ");
}
System.out.println("the smallest no. is"+y[0]);
System.out.println("the biggest no. is"+y[y.length-1]);
}
}
IF YOU HAVE ANY COMPLIMENTS OR ANY DOUBT EMAIL OR COMMENT BELOW