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

Here the condition is false on conditional operator, so the q value is assigned to r.



Your comments will be displayed only after manual approval.