-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpointersArray2.cpp
More file actions
56 lines (51 loc) · 988 Bytes
/
pointersArray2.cpp
File metadata and controls
56 lines (51 loc) · 988 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
50
51
52
53
54
55
56
#include <bits/stdc++.h>
using namespace std;
int getmin(int array[], int size)
{
int min = array[0];
for (int i = 1; i < size; i++)
{
if (min > array[i])
{
min = array[i];
}
}
return min;
}
int getmax(int array[], int size)
{
int max = array[0];
for (int i = 1; i < size; i++)
{
if (max < array[i])
{
max = array[i];
}
}
return max;
}
void getMin_Max(int array[], int size, int *max, int *min)
{
*max = array[0];
*min = array[0];
for (int i = 1; i < size; i++)
{
if (*max < array[i])
{
*max = array[i];
}
if (*min > array[i])
{
*min = array[i];
}
}
}
int main()
{
int number[] = {2, 3, 5, 67, -1};
int min=number[0], max=number[0];
getMin_Max(number, 5, &max, &min);
cout << "The min is " << min << endl;
cout << "The max is " << max << endl;
return 0;
}