Write a program in Java that accepts 25 numbers to a single dimensional array(SDA)
from the user. Display the biggest of the array elements.
Answers
Answered by
0
Answer:
Program:-
//Program using Scanner class
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int a[]=new int[25];
int max=0;
System.out.println("Enter the 1st element");
a[0]=in.nextInt();
max=a[0];
System.out.println("Enter the remaining elements");
for(int i=1;i<25;i++)
{
a[i]=in.nextInt();
}
for(int i=1;i<25;i++)
{
if(a[i]>max)
max=a[i];
}
System.out.println("The maximum element="+max);
in.close();
}
}
Output is attched.
Attachments:
Similar questions