Sunday, August 11, 2019

Sorting of Three Numbers in C++

A simple program that I wrote a long time ago to ask the user to give three numbers and then the program will sort the three numbers using C++ as our programming language.


I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


C++ Compiler and IDE that I used in writing this program Code Blocks



Sample Program Output

Program Listing


#include <iostream>

using namespace std;

int main(){

   int a=0, b=0, c=0;
   cout << "\t <====== SORTING THREE NUMBERS =====>";
   cout << "\n\n";
   cout<<"Please Enter Three Numbers :=> ";
   cin>>a>>b>>c;
   cout << "\n\n";
   cout<<"Numbers sorted in Ascending Order : ";
   if(a<b){

        if(a<c){
            cout<<a<<", ";

            if(c<b)
            cout<<c<<", "<<b<<"\n";
            else cout<<b<<", "<<c<<"\n";
        }
        else{
             cout<<c<<", ";
           if(a<b) cout<<a<<", "<<b<<"\n";
            else cout<<b<<", "<<a<<"\n";
        }
    }
    else{

        if(b<c){

            cout<<b<<", ";

           if(a<c) cout<<a<<", "<<c<<"\n";
            else cout<<c<<", "<<a<<"\n";
        }
        else{
             cout<<c<<", ";

           if(a<b) cout<<a<<", "<<c<<"\n";
            else cout<<b<<", "<<a<<"\n";
        }
    }
   cout << "\n\n";
   cout << "THANK YOU FOR USING THIS PROGRAM";
   cout << "\n\n";
   system("pause");
}





No comments:

Post a Comment