Answer to Question #15205 in Action Script | Flash | Flex | ColdFusion for anosha

Question #15205
Write a C++ program that declares three variables minNum, midNum and maxNum to receive three integers read from the keyboard. The inputs are unsorted and can be read into the three variables in any order, for example, the first read number in minNum may not be the smallest. However, your program should then sort the three numbers to ensure minNum ≤ midNum ≤ maxNum and display them in this order. has to be in ascending order thank you
Expert's answer
#include <iostream>
using namespace std;
int main (){

int minNum, midNum, maxNum;

cout<<"Enter numbers please!\n";

cin>> minNum >> midNum >> maxNum ;

if (minNum > midNum) swap(midNum,minNum);
if (midNum > maxNum) swap(midNum,maxNum);
if (minNum > midNum) swap(midNum,minNum);
cout<< minNum << ' ' << midNum << ' ' << maxNum <<endl;

return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog