-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprog4.cpp
More file actions
33 lines (22 loc) · 770 Bytes
/
prog4.cpp
File metadata and controls
33 lines (22 loc) · 770 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
/*
Write a prograam to find the largest, smallest and second largest number of
three numbers.
(Use inline functions MAX and MIN to find largest and smallest of two numbers)
Concept: Inline Functions
*/
#include <iostream>
using namespace std;
inline int MAX(int a, int b) { return (a > b) ? a : b; }
inline int MIN(int a, int b) { return (a < b) ? a : b; }
int main() {
int a, b, c, largest, secondLargest, smallest;
cout << "Enter three numbers: " << endl;
cin >> a >> b >> c;
largest = MAX(a, MAX(b, c));
smallest = MIN(a, MIN(b, c));
secondLargest = MIN(a, MAX(b, c));
cout << "Largest number: " << largest << endl;
cout << "Second Largest number: " << secondLargest << endl;
cout << "Smallest number: " << smallest << endl;
return 0;
}