Computer Science, asked by RishitaRaghvan, 3 months ago

write a program to input 10 different numbers.display the greatest and the smallest numbers among them in Java ​

Answers

Answered by anjumnaazz2465
3

Answer:

I hop I will help you.

Explanation:

I could get the largest without using arrays but, unable to get the smallest one.

public static void main(String[] args)

{

int smallest=0;

int large=0;

int num;

System.out.println("enter the number");

Scanner input=new Scanner(System.in);

int n=input.nextInt();

for(int i=0;i<n;i++)

{

num=input.nextInt();

if(num>large)

{

large=num;

}

System.out.println("the largest is:"+large);

//gives the largest number in n

Similar questions