2012-08-14T08:21:50-04:00
read 5 numbers and print out their in ascending order using do while without using array
1
2012-08-16T10:34:56-0400
#include <iostream> #include <stdio.h> using namespace std; void swap(int &a, int &b){ int c = a; a = b; b = c; } int main(){ int a,b,c,d,e; cout<<"Input 5 numbers "; cin>>a; cin>>b; cin>>c; cin>>d; cin>>e; do{ if(d > e) swap(d,e); if(c > d) swap(c,d); if(b > c) swap(b,c); if(a > b) swap(a,b); } while (! ((a <= b) && (b <= c) && (c <= d) && (d <= e)) ) ;//while not sorted cout<<a<<b<<c<<d<<e<<endl; system("pause"); 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 !
Learn more about our help with Assignments:
C++
Comments