In: Computer Science
(17pts)Write, compile, and test a C++ program that uses an if-else structure for problem 3.7 on page 108.
Use the format specified earlier (initial block of comments with TCC logo, name, etc)
Display instructions so that the user understands the purpose of the program and what to enter.
Display the results in increasing (non-decreasing) order.
Run the program for the following 6 test cases.Turn in a printout of the program and printouts of the 6 test cases.(The result should be the same in all 6 cases!)
Case 1stnumberentered 2ndnumberentered 3rdnumberentered
1 10 20 30
2 10 30 20
3 20 10 30
4 20 30 10
5 30 10 20
6 30 20 10
#include <iostream>
using namespace std;
int main()
{
int num1, num2, num3, smallest, middle, biggest;
cout<< "Enter first number:\t";
cin>> num1;
cout<< "Enter second number:\t";
cin>> num2;
cout<< "Enter third number:\t";
cin>> num3;
if ((num1 < num2) && (num1 < num3))
{
smallest = num1;
if (num2 > num3)
{
biggest = num2;
middle = num3;
}
}
if ((num1 < num2) && (num3 << num1))
{
smallest = num1;
if (num2 < num3)
{
middle = num2;
biggest = num3;
}
}
if ((num1 > num2) && (num3 > num1))
{
middle = num1;
if (num2 < num3)
{
smallest = num2;
biggest = num3;
}
}
if ((num1 < num2) && (num3 < num1))
{
middle = num1;
if (num2 > num3)
{
biggest = num2;
smallest = num3;
}
}
if ((num1 > num2) && (num1 > num3))
{
biggest = num1;
if (num3 > num2)
{
middle = num3;
smallest = num2;
}
}
if ((num1 > num2) && (num1 > num3))
{
biggest = num1;
if (num2 > num3)
{
middle = num2;
smallest = num3;
}
}
cout<< "Ascending order is : ";
cout << smallest << ", " << middle << ", "
<< biggest << endl;
return 0;
}