forked from Shubhamlmp/Programming-Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path32_max.cpp
23 lines (21 loc) · 779 Bytes
/
32_max.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//Given a number N, and N numbers, find maximum number in these N numbers.
#include <iostream> //iostream is a header file that contains basic input/output functions
using namespace std; //std is the standard namespace
int main() //main function
{
int n; //declaring a variable n
cin >> n; //taking input from user
int max = -1000000000; //declaring a variable max and assigning it a value of -1000000000
for (int i = 0; i < n; i++) //for loop
{
int x; //declaring a variable x
cin >> x; //taking input from user
if (x > max) //if x is greater than max
{
max = x; //assigning x to max
}
}
cout << max << endl; //printing max
return 0; //returning 0
//end of program
}