Descending C++ Code



The Program will ask you 3 Numbers and it will arrange it from highest to the lowest


here is the code:
#include <iostream>

using namespace std;
int x=2;
int check (int a, int b, int c)
{
    int d=a;
    
    if (x==0) 
    {
              if (b>c)
              {
                     cout<<"\n The highest value of them is = "<<a<<" then "<<b<<" then "<<c<<endl;
              }
              else 
                     cout<<"\n The highest value of them is = "<<a<<" then "<<c<<" then "<<b<<endl;
                      
    
    return(0);
    }
    if (a>b)
    {
            
            x=x-1;
            check(a,c,b);
    }       
    else 
    {
            x=x-1;
            check(b,c,a);
    }
}

int main()
{
      int a,b,c;
      cout<<"First value = ";cin>>a;
      cout<<"\nSecond value = ";cin>>b;
      cout<<"\nThird value = ";cin>>c;
      check(a,b,c);
      
      system("Pause");
      return 0;
}



0 komentar:

Posting Komentar