Quiz: Operators

To View Tricks: Login Required

Number of Questions: 15

Question: 1 -

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

Options:
  1. Addition and subtraction

  2. Function call

  3. Array subscripting

  4. Type cast

  5. Answer:

    Type cast

    Solution not available.

Question: 2 -

In which direction does the assignment operation will take place?

Options:
  1. left to right

  2. bottom to top

  3. top to bottom

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

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 +, |, <=.


Question: 4 -

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:10 b:4

  3. a:4 b:10

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

Pick out the compound assignment statement.

Options:
  1. a = a + 5

  2. a = a / b

  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.