write a program to input an array and find the maximum value and minimum value elements with its index value and print it
Answers
Answered by
7
importjava.util.*;
class hi
{
public void main()
{
Scanner sc= new Scanner(System.in);
int m[ ]= new int[10];
int i,max=0,min=0;
System.out.println("enter numbers in the array");
for(i=0;i<10;i++)
{
m[i]=sc.nextInt();
}
for(i=0;i<10;i++)
{
if (m[i]<min)
{
min=m[i];
}
if(m[i]>max)
{
max=m[i];
}
}
System.out.println("maximum="+max);
System.out.println("minimum="+min);
}
}
Similar questions