Computer Science, asked by tusharsamy, 9 months ago

using java write a program to input any 10 integers and print the largest and second largest number in the given set of integers assume no duplicate no in the set of the number ​

Answers

Answered by CopyThat
3

Answer:

Explanation:

import java.util.*;

public class Brainly

{

static void main()

{

Scanner sc=new Scanner(System.in);

int i,n,l=0,sl=0;

System.out.println("Enter 10 numbers:");

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

{

n=sc.nextInt();

if(i==1)

l=n;

else

{

if(n>l)

{

sl=l;

l=n;

}

else if(sl==0)

sl=n;

else if(n>sl)

sl=n;

}

}

System.out.println("Second Largest Number="+sl);

}

}

Similar questions