-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram2.cpp
More file actions
32 lines (27 loc) · 731 Bytes
/
Program2.cpp
File metadata and controls
32 lines (27 loc) · 731 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
// Program to find highest and lowest element in an array.
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Umesh Patel\nEnrollment Number: 0126AL231140\n";
cout << "Enter the number of elements in the array: ";
cin >> n;
int arr[n];
for(int i = 0; i < n; i++)
{
cout << "Enter element " << i + 1 << ": ";
cin >> arr[i];
}
int max = arr[0], min = arr[0];
for(int i = 1; i < n; i++)
{
if(arr[i] > max)
max = arr[i];
if(arr[i] < min)
min = arr[i];
}
cout << "The highest element in the array is: " << max << endl;
cout << "The lowest element in the array is: " << min << endl;
return 0;
}