Start New Discussion within our Software Development Community

I have a code that suppose to prompt a user for thre numbers and output them in ascending order but i get the wrong results for example if i put in 476 it output 764 and i am trying to fix this and add the comments of havigng it prompt for the iputs

#include <iostream>
// for being able to use library functions
using namespace std;
int main()
{
    // declare three variables
    int a,b,c;
    // take inputs from command line
    cin>>a>>b>>c;
    if(a>b && a>c)
    {
        cout<<a<<endl;
        if(b>c)
        {
            cout<<b<<endl;
            cout<<c<<endl;
        }
        else
        {
            cout<<c<<endl;
            cout<<b<<endl;
        }
    }
    else if(b>a && b>c)
    {
        cout<<b<<endl;
        if(a>c)
        {
            cout<<a<<endl;
            cout<<c<<endl;
        }
        else
        {
            cout<<c<<endl;
            cout<<a<<endl;
        }
    }

    else if(c>a && c>b)
    {
        cout<<c<<endl;
        if(b>a)
        {
            cout<<b<<endl;
            cout<<a<<endl;
        }
        else
        {
            cout<<a<<endl;
            cout<<b<<endl;
        }
         cin.get();  // for stopping the window
    cin.ignore(); // from closing
    return 0;
    }
    }
This article has been dead for over six months. Start a new discussion instead.