-
Notifications
You must be signed in to change notification settings - Fork 0
/
c2.cpp
42 lines (42 loc) · 815 Bytes
/
c2.cpp
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
#include <iostream>
using namespace std;
int min(int arr[], int n)
{
int min = arr[0];
for (int i = 1; i < n; i++)
{
if (min > arr[i])
{
min = arr[i];
}
}
return min;
}
int max(int arr[], int n)
{
int max = arr[0];
for (int i = 1; i < n; i++)
{
if (max < arr[i])
{
max = arr[i];
}
}
return max;
}
int main()
{
int n;
cout<<"Size of array?";
cin >> n;
int arr[n];
cout<<"Enter the elements of the array";
// array input
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
int mini = min(arr, n);
int maxi = max(arr, n);
cout << "minimum and maximum elements of array are " << mini << " and " << maxi << endl;
}