-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray_Max_Min.cpp
More file actions
63 lines (41 loc) · 779 Bytes
/
Array_Max_Min.cpp
File metadata and controls
63 lines (41 loc) · 779 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
57
58
59
60
61
62
63
//WAP to print the minimum value and the maximum value stored in the array.
#include<iostream>
using namespace std;
int Array_Min_Max(int arr[],int size)
{
int ArrayMax=arr[0],ArrayMin=arr[0];
//for MAX
for (int i = 1; i < size; i++)
{
if (arr[i]>ArrayMax)
{
ArrayMax=arr[i];
}
}
//for MIN
for (int i = 1; i < size; i++)
{
if (arr[i]<ArrayMin)
{
ArrayMin=arr[i];
}
}
cout<<"the max no of array is:-"<<endl;
cout<<ArrayMax<<endl;
cout<<"the min value of array is:-"<<endl;
cout<<ArrayMin;
}
int main()
{
int s;
cout<<"enter the size of the array"<<endl;
cin>>s;
int demo_array[s];
cout<<"enter the elements of the array"<<endl;
for (int i = 0; i < s; i++)
{
cin>>demo_array[i];
}
Array_Min_Max(demo_array,s);
return 0;
}