Computer Science, asked by subhasishbehera083, 4 months ago

Input 10 elements in an array and display maximum and minimum value along with their positions​

Answers

Answered by kamalrajatjoshi94
0

Answer:

import java.util.*;

public class Display

{

public static void main(String args[ ])

{

Scanner in=new Scanner(System.in);

int max=0,min=0;

int n[ ]=new int[1];

int m[ ]=new int[9];

System.out.println("Enter the first element");

n[0]=in.nextInt();

max=n[0];

min=n[0];

System.out.println("Enter the remaining 9 elements");

for(int i=1;i<10;i++)

{

m[i]=in.nextInt();

if(m[i]<min)

min=m[i];

if(m[i]>max)

max=m[i];

}

System.out.println("The greatest element="max +"at position"+(i+1));

System.out.println("The smallest element="+min+" at position"+(i+1));

}

}

Similar questions