Home » C++ Programming » Operators » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    int main ()
    {
    int p, q, R;
    p = 5;
    q = 3;
    R = (p > q) ? p : q;
    cout << R;
    return 0;
    }
    1. 3
    2. Compilation Error
    3. Runtime Error
    4. Garbage value
    5. 5
Correct Option: E

We are using the ternary operator to evaluate this expression. It will return first option, if first condition is true otherwise it will return second



Your comments will be displayed only after manual approval.