Tuesday, October 4
Shadow

Greatest of three numbers

#include <iostream>
#include<math.h>
using namespace std;

int main() {
    int n1,n2,n3;
    n1=78, n2=65, n3=10;
    /*if(n1>n2){  method 1
        if(n1>n3){
            cout<<n1;
        }
        else{
            cout<<n3;
        }
    }
    else{
        if(n2>n3){
            cout<<n2;
        }
        else{
            cout<<n3;
        }
    }*/
    //int m=max(n1,n2);  //method 2
    //cout<<max(m,n3);
    //if((n1>n2)?((n1>n3)?cout<<n1:cout<<n3):((n2>n3)?cout<<n2:cout<<n3));  //method 3
    /*if(n1>n2 && n1>n3)  //method 4
        cout<<n1;
    else if(n1>n2  && n2>n3)
        cout<<n2;
    else
        cout<<n3;*/
    cout<<max(n3,max(n1,n2));  //method 5
    
    return 0;
}

Leave a Reply