Answer to Question #157601 in C++ for seada

Question #157601

Receive 3 numbers and display them in ascending order from smallest to largest


1
Expert's answer
2021-01-22T07:37:14-0500
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int a = 0;
    int b = 0;
    int c = 0;
    cin >> a >> b >> c;
    if (a > b)
        swap(a, b);
    if (b > c)
        swap(b , c);
    if (a > b)
        swap(a ,b);
    cout << a << ' ' << b << ' ' << c << 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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog