forked from Harry-003/Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmax_min_Array
More file actions
45 lines (43 loc) · 814 Bytes
/
max_min_Array
File metadata and controls
45 lines (43 loc) · 814 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
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;
int max(int A[],int n)
{
int max=A[0];
for(int i=0;i<n;i++)
{
if(A[i]>max)
{
max=A[i];
}
}
return max;
}
int min(int A[],int n)
{
int min=A[0];
for(int i=0;i<n;i++)
{
if(A[i]<min)
{
min=A[i];
}
}
return min;
}
int main() {
int n;
cout<<"Enter the length of the array:";
cin>>n;
int A[n];
cout<<"Enter the elements of the array:";
for(int i=0;i<n;i++)
{
cin>>A[i];
}
int p=max(A,n);
int q=min(A,n);
cout<<"Maximum number of the array;"<<p<<endl;
cout<<"Minimum number of the array;"<<q<<endl;
return 0;
}