Question: Please edit the following C++ program using the for loop to repeat the process of sorting at least 3 times. #include using namespace std; int
Please edit the following C++ program using the for loop to repeat the process of sorting at least 3 times.
#include
using namespace std;
int main()
{
bool Continue=1;
int a;
int b;
int c;
while (Continue==1)
{
cout << "Type three numbers"<< endl;
cin >> a >> b >> c;
if(a < b && b < c)
{
cout << "Lowest to highest" << endl;
cout << a <<" "<< b <<" "<< c << endl;
}
if (b < a && a < c)
{
cout << "Lowest to highest" << endl;
cout << b <<" "<< a <<" "<< c << endl;
}
if (a < c && c < b)
{
cout << "Lowest to highest" << endl;
cout << a <<" "<< c <<" "<< b << endl;
}
if (b < c && c < a)
{
cout << "Lowest to highest" << endl;
cout << b <<" "<< c <<" "<< a << endl;
}
if (c < b && b < a)
{
cout << "Lowest to highest" << endl;
cout << c <<" "<< b <<" "<< a << endl;
}
if (c < a && a < b)
{
cout << "Lowest to highest" << endl;
cout << c <<" "<< a <<" "<< b << endl;
}
//descending
if(a > b && b > c)
{
cout << "Highest to Lowest" << endl;
cout << a <<" "<< b <<" "<< c << endl;
}
if (b > a && a > c)
{
cout << "Highest to Lowest" << endl;
cout << b <<" "<< a <<" "<< c << endl;
}
if (a > c && c > b)
{
cout << "Highest to Lowest" << endl;
cout << a <<" "<< c <<" "<< b << endl;
}
if (b > c && c > a)
{
cout << "Highest to Lowest" << endl;
cout << b <<" "<< c <<" "<< a << endl;
}
if (c > b && b > a)
{
cout << "Highest to Lowest" << endl;
cout << c <<" "<< b <<" "<< a << endl;
}
if (c > a && a > b)
{
cout << "Highest to Lowest" << endl;
cout << c <<" "<< a <<" "<< b << endl;
}
cout<< "Would you like to continue? Enter 1 for yes and 0 for no." < cin>>Continue; } system("pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
