-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1st.cpp
More file actions
33 lines (26 loc) · 756 Bytes
/
1st.cpp
File metadata and controls
33 lines (26 loc) · 756 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
// Program for Second largest number among the three numbers
#include <iostream>
using namespace std;
int main(){
int num1, num2, num3;
int seclarge;
cout<<"Enter the first number - ";
cin>>num1;
cout<<"Enter the second number - ";
cin>>num2;
cout<<"Enter the third number - ";
cin>>num3;
// Using if-else and logical operator
if ((num1 > num2 && num1 < num3) || (num1 > num3 && num1 < num2)){
seclarge = num1;
}
else if ((num2 > num1 && num2 < num3) || (num2 < num1 && num2 > num3)){
seclarge = num2;
}
else{
seclarge = num3;
}
//Printing the third largest number
cout<<"Second largest number is "<<seclarge;
return 0;
}