Operators


  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    int main()
    {
    int Number1 = 7;
    int Number2 = 5;
    if ( Number1 && Number2 )
    {
    cout << "True"<< endl ;
    }
    else
    {
    cout << "False"<< endl ;
    }
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    && is called as Logical AND operator, if there is no zero in the operand means, it will be true otherwise True.


  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. View Hint View Answer Discuss in Forum

    NA

    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



  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    int main ()
    {
    int num1, num2;
    num1 = 6;
    num2 = 5;
    num1 = num2;
    num2 = 3;
    cout << "num1:";
    cout << num1;
    cout << ", num2:";
    cout << num2;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    In this program, we are reassigning the values of num1 and num2 because of this we got the output as num1:5 num2:3


  1. Pick out the compound assignment statement.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    When we want to modify the value of a variable by performing an operation on the value currently stored, We will use compound assignment statement. In this option, p -=6 is equal to p = p-6.