Quiz: Operators

To View Tricks: Login Required

Number of Questions: 15

Question: 1 -

Pick out the compound assignment statement.

Options:
  1. a = a / b

  2. a -= 5

  3. a = a + 5

  4. a = a – 5

  5. Answer:

    a -= 5

    Solution:

    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, a -=5 is equal to a = a-5.


Question: 2 -

Which operator is having the right to left associativity in the following?

Options:
  1. Array subscripting

  2. Function call

  3. Addition and subtraction

  4. Type cast

  5. Answer:

    Type cast

    Solution not available.

Question: 3 -

What will be the output of the following C++ code?

#include <iostream>
using namespace std;
int main() {

    int a, b;
    a = 10;
    b = 4;
    a = b;
    b = 7;
    cout << "a: " << a;
    cout << "\nb: " << b;

    return 0;
}

Options:
  1. a:4 b:7

  2. a:4 b:6

  3. a:4 b:10

  4. a:10 b:4

  5. Answer:

    a:4 b:7

    Solution:

    In this program, we are reassigning the values of a and b because of this we got the output as a:4 b:7


Question: 4 -

In which direction does the assignment operation will take place?

Options:
  1. bottom to top

  2. right to left

  3. top to bottom

  4. left to right

  5. Answer:

    right to left

    Solution:

    In assignment operation, the flow of execution will be from right to left only.


Question: 5 -

What are the essential operators in c++?

Options:
  1. All of the mentioned

  2. +

  3. <=

  4. |

  5. Answer:

    All of the mentioned

    Solution:

    Explanation: Essential operators in c++ are +, |, <=.