-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.cpp
More file actions
41 lines (32 loc) · 684 Bytes
/
Copy patharray.cpp
File metadata and controls
41 lines (32 loc) · 684 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
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int max = INT_MIN;
int input[100]; // create array of constant length.
// taking input of array from user.
for (int i = 0; i < n; i++)
{
cin >> input[i];
}
cout << "Elements in the array are: "
<< " ";
// printing values of array.
for (int j = 0; j < n; j++)
{
cout << input[j] << " ";
}
cout << endl;
// largest element from array:
for (int k = 0; k < n; k++)
{
if (input[k] > max)
{
max = input[k];
}
}
cout << "Maximum element is: " << max << endl;
return 0;
}