Write a program that takes three integers and outputs them in a descending order, i.e., for the largest to the smallest number. For example, if the user enters 45, 100, 30, the program should output 100, 45, 30.
******THIS PROGRAM IS TO BE WRITTEN IN C++
#include <iostream>
using namespace std;
int main()
{
int a, b, c;
cout<<"Inter 3 Number: ";
cin>>a>>b>>c;
// if a is bigger number
if( a > b && a > c){
if(b > c) {
cout<<a<<" "<<b<<"
"<<c<<endl;
} else {
cout<<a<<" "<<c<<"
"<<b<<endl;
}
}
// else if b is bigger number
else if(b > c){
if(a > c) {
cout<<b<<" "<<a<<"
"<<c<<endl;
} else {
cout<<b<<" "<<c<<"
"<<a<<endl;
}
}
// if c is bigger
else {
if(a > b) {
cout<<c<<" "<<a<<"
"<<b<<endl;
} else {
cout<<c<<" "<<b<<"
"<<a<<endl;
}
}
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.