Quiz: Operators

To View Tricks: Login Required

Number of Questions: 15

Question: 1 -

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:6

  2. a:4 b:10

  3. a:10 b:4

  4. a:4 b:7

  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: 2 -

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

Options:
  1. Addition and subtraction

  2. Array subscripting

  3. Type cast

  4. Function call

  5. Answer:

    Type cast

    Solution not available.

Question: 3 -

In which direction does the assignment operation will take place?

Options:
  1. top to bottom

  2. bottom to top

  3. left to right

  4. right to left

  5. Answer:

    right to left

    Solution:

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


Question: 4 -

Pick out the compound assignment statement.

Options:
  1. a = a / b

  2. a = a + 5

  3. a = a – 5

  4. 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: 5 -

What are the essential operators in c++?

Options:
  1. +

  2. <=

  3. |

  4. All of the mentioned

  5. Answer:

    All of the mentioned

    Solution:

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