Computer Science, asked by aditichauhan69, 1 year ago

write a program to input 10 integers and display the largest among them

Answers

Answered by Anonymous
10

JAVA CODE :


import java.util.*;

class largest_integer

{

public void main()

{

Scanner sc=new Scanner(System.in);

int a[]=new int[10];

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

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

{

a[i]=sc.nextInt();

}

int max=0;

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

{

if(a[i]>max)

{

max=a[i];

}

}

System.out.println("The largest integer is :"+a[i]);

}

}

----------------------------------------------------------------------------

OUTPUT :

Enter 10 numbers

1

2

3

4

5

6

7

8

9

10

The largest integer is :10

Hope it helps

____________________________________________________________________


Anonymous: welcome:-)
Anonymous: I am busy today tomorrow I will go to your profile and answer all questions ok
Answered by duragpalsingh
1

Question:

Write a program to input 10 integers and display the largest among them

Solution:

Languge used: Java

[ Without using array]

-------------------------------------------------------------------------------

import java.util.*;

public class Question

{

static void main()

{

Scanner sc=new Scanner(System.in);

int i,n,l=0;

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

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

{

n=sc.nextInt();

if(i==1)

l=n;

else if(n>l)

l=n;

}

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

}

}

Similar questions