Question

Write a program that takes three integers and outputs them in a descending order, i.e., for...

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++

Homework Answers

Answer #1

#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;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Q :     Write a C++ program that asks the user to enter three integers and...
Q :     Write a C++ program that asks the user to enter three integers and then displays the largest one. Example : if the user enter ( 7, 2 ,5) the largest number will be 7 Or if user enter ( 2 , 5 , 7 ) the largest number will be 7 Or if user enter ( 7, 5 ,2) the largest number will be 7 In general it does not matter the order of the entered numbers...
JAVA: Write a program that takes in a line of text as input, and outputs that...
JAVA: Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters “done” (case-insensitive) for the line of text. Note: You are not supposed to use any in-build methods to reverse the text. Example: Enter a series of strings: Hello there Hey done the output is: ereht olleH yeH
In Python: Problem 4. Write a program [call it minmax.py] that accepts three integers in the...
In Python: Problem 4. Write a program [call it minmax.py] that accepts three integers in the range [0-100] as input from the user. Your program should then determine and print the smallest and largest integers in the values entered by the user using comparison operators *not* using predefined min or max Python functions. For instance: If the user input is: 36 5 99 your program should give as output: min = 5 max = 99 If the user input is:...
Write a program that takes in a line of text as input, and outputs that line...
Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text. Ex: If the input is: Hello there Hey quit the output is: ereht olleH yeH IN JAVA
Please write code in C. Thank you! Write a program that reads a list of integers,...
Please write code in C. Thank you! Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow. You can assume that the list will have at least 2 integers and less than 20 integers. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 3 To achieve the above, first read...
In C++ Prompt the user to enter three integers •Calculate the average of the three integers....
In C++ Prompt the user to enter three integers •Calculate the average of the three integers. •Output the largest number among three values. •Display the three numbers from the smallest to the largest.
In Coral,write a program that reads a list of 10 integers and outputs those Integers in...
In Coral,write a program that reads a list of 10 integers and outputs those Integers in Reverse. For coding Simplicity, follow each output integer by a space, including the last one. Then, output a new line. Example if the input is 2 4 6 8 10 12 14 16 18 20, the output is: 20 18 16 14 12 10 8 6 4 2 to achieve above first read the integers into an array. Then output the array in reverse
Its a c++ task. Write a program that reads 10 integers from the user into an...
Its a c++ task. Write a program that reads 10 integers from the user into an array and uses a function arrayMinimum that accepts an integer array a along with its size arraySize as parameters and returns the smallest array element. The program then outputs the result (the smallest array element).
JAVA: Write a short program that takes as input three integers, a, b, and c, and...
JAVA: Write a short program that takes as input three integers, a, b, and c, and determines if they ca be used in a correct arithmetic formula(in the given order) like "a+b=c", "a=b-c", or "a*b=c"
In C++ program that inputs three integers and displays the smallest and largest numbers. It should...
In C++ program that inputs three integers and displays the smallest and largest numbers. It should pass the numbers to two functions. A value returning function determines the smallest number and returns it, and a void function determines the largest number and displays it. Sample run: Enter three numbers: 9 10 7 The smallest number is:7 The largest number is: 10
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • What new items will you need to replace a failing processor? Select all that apply.   ...
    asked 18 minutes ago
  • A system is to be developed for an airport. When passengers have boarded an aircraft, a...
    asked 26 minutes ago
  • After reading Module 5 PowerPoint 1 - The Philosophy of Human Existance and Health Care Policy,...
    asked 35 minutes ago
  • 1. Do you feel play has a place in supporting literacy development in early childhood? Explain...
    asked 38 minutes ago
  • How should roles be selected for the Emergency Operations Center (EOC)?  Is seniority less important than experience?...
    asked 51 minutes ago
  • Discuss routing issues and solutions namely, count-to-infinity, split horizon, split horizon with poison reverse, and hold-down...
    asked 51 minutes ago
  • Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is〈5,10,3,12,5,50,6〉.
    asked 1 hour ago
  • Water at 60 F (density=62.4lbm/ft^3 and dynamic viscosity = 7.5x10^-4 lbm/ft-s) is to be pumped through...
    asked 1 hour ago
  • ibuprofen an aspirin substitute has the following percent composition C, 75.69%; H,8.80%; O,15.51%. determine the empirical...
    asked 1 hour ago
  • Describe in brief some of the aspects of understanding words in the study of language
    asked 1 hour ago
  • Anticipated sales for Safety Grip Company were 75,000 passenger car tires and 23,000 truck tires. Rubber...
    asked 1 hour ago
  • QUESTION ONE a) Differentiate between traceable and common costs b) Assume that you are living in...
    asked 1 hour ago