-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElementLarger.java
More file actions
32 lines (30 loc) · 838 Bytes
/
ElementLarger.java
File metadata and controls
32 lines (30 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.Scanner;
public class ElementLarger {
public static void main(String[] args) {
Scanner A=new Scanner(System.in);
int arr[]=new int[100];
System.out.print("Enter a size of array :- ");
int n=A.nextInt();
System.out.println("Entert a element of Array :- ");
for(int i=0;i<n;i++){
arr[i]=A.nextInt();
}
System.out.println("Display a Array :- ");
for(int i=0;i<n;i++){
System.out.print(arr[i]+" ");
}
int max=arr[0];
int min=arr[0];
for(int i=0;i<n;i++){
if(arr[i]>max){
max=arr[i];
}
if(arr[i]<min){
min=arr[i];
}
}
System.out.println("The Maximum Element of Array is :- "+max);
System.out.println("The Minimum Element of Array is :- "+min);
A.close();
}
}