Write a program to enter 20 numbers and find
out the maximum
and minimum value.
Answers
Answered by
0
Answer:
import java.util.*;
public class max_min
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int max,min,n;
System.out.println("Enter a number");
n=sc.nextInt();
min=n;
max=n;
for(int i=1;i<=10;i++)
{
System.out.println("Enter a number");
n=sc.nextInt();
if(n<min)
min=n;
if(n>max)
max=n;
}
System.out.println("Maximum value="+max);
System.out.println("Minimum value="+min);
}
}
Similar questions