Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

nested conditional operator

	cout << "Execute expression using "
    << "ternary operator: ";
    int a = 2 > 3 ? 2 : 3 > 4 ? 3 : 4;
    cout << a << endl;
      
    cout << "Execute expression using "
    << "if else statement: ";
    if ( 2 > 3 )
        cout << "2";
    else if ( 3 > 4 )
        cout << "3";
    else 
        cout << "4";
 
PREVIOUS NEXT
Tagged: #nested #conditional #operator
ADD COMMENT
Topic
Name
9+8 =