nested conditional operator

Solutions on MaxInterview for nested conditional operator by the best coders in the world

showing results for - "nested conditional operator"
Nikki
23 Aug 2019
1	cout << "Execute expression using "
2    << "ternary operator: ";
3    int a = 2 > 3 ? 2 : 3 > 4 ? 3 : 4;
4    cout << a << endl;
5      
6    cout << "Execute expression using "
7    << "if else statement: ";
8    if ( 2 > 3 )
9        cout << "2";
10    else if ( 3 > 4 )
11        cout << "3";
12    else 
13        cout << "4";