DEV Community

Mohammed Salah
Mohammed Salah

Posted on

C++28th code (The ternary operator in C++ )

    #include<iostream>
    using namespace std; 
    int main()
    {
float a,b;
cout<<" \n\tEnter First number : "; 
cin >> a; 
cout<<"\n\t  ===========================\n "; 
cout<<"\n\t Enter Second number : " ; 
cin>>b; 
cout<<"\n\t  ===========================\n "; 
//The ternary operator in C++
//condition ? expression1 : expression2;
float Max = (a>b)? (a): (b);
cout<<"\n\t The Max Value is = "<<Max; 
cout<<"\n\n\t  ===========================\n "; 
cin.get();
return 0 ; 
    }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)