-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAcendingOrder(If,Else).txt
59 lines (48 loc) · 1.6 KB
/
AcendingOrder(If,Else).txt
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
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
//Variable declaration
int num1,num2,num3;
//Terminal Output
cout << "\nThis program will output 3 inputs in ascending order."<<endl;
cout<< "Please enter numbers followed by a space:"<<endl;
//User Input
cin >> num1 >> num2 >> num3;
cout << "\nThe numbers entered are: " << num1 << ", " << num2 << ", and " << num3 <<endl;
/*
Using if statements and the && we will determine which number is the greatest. After determing which one is
the bigger one we will compare with the two other inputs and display them in ascending order. We are using
methods up until chapter 4.
*/
if (num1 > num2 && num1 > num3 )
{
if(num2 > num3){
cout << "In ascending order: " << num3 <<", " <<num2 << ", and " <<num1 <<endl;
}
else{
cout << "In ascending order: " << num2 <<", " <<num3 << ", and " <<num1 <<endl;
}
}
if (num2 > num1 && num2 > num3 )
{
if(num1 > num3){
cout << "In ascending order: " << num3 <<", " <<num1 << ", and " <<num2 <<endl;
}
else{
cout << "In ascending order: " << num1 <<", " <<num3 << ", and " <<num2 <<endl;
}
}
if (num3 > num2 && num3 > num1 )
{
if(num2 > num1){
cout << "In ascending order: " << num1<<", " <<num2 << ", and " <<num3 <<endl;
}
else{
cout << "In ascending order: " << num2 <<", " <<num1 << ", and " <<num3 <<endl;
}
}
cout << "\nGoodbye..." <<endl;
return 0;
}