63 140
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #14443 in Action Script | Flash | Flex | ColdFusion for enjila

Question #14443
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.
Expert's answer
#include<iostream>
using namespace std;


void f(float &x, float &y)
{
float t;
t = x;
x = y;
y=t;
}
int main()
{
& float minNum,midNum,maxNum;
&
& cout <<" Enter minNum: ";
& cin>>minNum;
cout <<" Enter midNum: ";
cin>>midNum;
cout <<" Enter maxNum: " ;
cin>>maxNum;

if(minNum>midNum)f(minNum,midNum);

if(minNum>maxNum)f(minNum,maxNum);
if(midNum>maxNum)f(midNum,maxNum);

cout <<"\nSorting\n minNum : "<<minNum;
&
cout <<"\n midNum : "<<midNum;

cout <<"\n maxNum : "<<maxNum <<"\n\n";



system("PAUSE");
}

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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions