-
Notifications
You must be signed in to change notification settings - Fork 1
/
Ascending And Descending Order.cpp
60 lines (54 loc) · 1.47 KB
/
Ascending And Descending Order.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
using namespace std;
int main() {
float a, b, c;
cout << "Enter three numbers: " << endl;
cin >> a >> b >> c;
cout << "In Ascending Order: ";
if (a <= b && b <= c) {
cout << a << " " << b << " " << c;
}
else if (a <= c && c <= b) {
cout << a << " " << c << " " << b;
}
else if (b <= a && a <= c) {
cout << b << " " << a << " " << c;
}
else if (b <= c && c <= a) {
cout << b << " " << c << " " << a;
}
else if (c <= a && a <= b) {
cout << c << " " << a << " " << b;
}
else if (c <= b && b <= a) {
cout << c << " " << b << " " << a;
}
else {
cout << "All three numbers are equal: " << a << " " << b << " " << c;
}
cout << endl;
cout << "In Descending Order: ";
if (a >= b && b >= c) {
cout << a << " " << b << " " << c;
}
else if (a >= c && c >= b) {
cout << a << " " << c << " " << b;
}
else if (b >= a && a >= c) {
cout << b << " " << a << " " << c;
}
else if (b >= c && c >= a) {
cout << b << " " << c << " " << a;
}
else if (c >= a && a >= b) {
cout << c << " " << a << " " << b;
}
else if (c >= b && b >= a) {
cout << c << " " << b << " " << a;
}
else {
cout << "All three numbers are equal: " << a << " " << b << " " << c;
}
cout << endl;
return 0;
}