-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaxMinarray.java
More file actions
49 lines (46 loc) · 965 Bytes
/
MaxMinarray.java
File metadata and controls
49 lines (46 loc) · 965 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.Scanner;
class MaxMinarray
{
void min(int[] f)
{
int min=f[0];
for(int i=0;i<f.length;i++)
{
if(f[i]<min)
min=f[i];
}
System.out.println("The minimum value of Array is : "+min);
}
void max(int[] f)
{
int max=0;
for(int i=0;i<f.length;i++)
{
if(f[i]>max)
max=f[i];
}
System.out.println("The maximum value of Array is : "+max);
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the Array : ");
int y=sc.nextInt();
int[] a=new int[y];
MaxMinarray m=new MaxMinarray();
System.out.println("Enter "+y+" elements of Array : ");
for(int i=0;i<y;i++)
{
System.out.println("Enter value of "+i+" index : ");
a[i]=sc.nextInt();
}
System.out.println("Printing Array : ");
for(int i=0;i<y;i++)
{
System.out.print(a[i]+" ");
}
System.out.println(" ");
m.max(a);
m.min(a);
}
}