C++ Operators

This quiz tests your knowledge of C++ operators. It contains 10 questions.

Last Updated :
Discuss
Comments

Question 1

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

  • Array subscripting

  • Function call

  • Addition and Subtraction

  • Type cast

Question 2

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

#include <iostream>
using namespace std;
int main() {
   int a = 0;
   int b = 10;
   a = 2;
   b = 7;
   if (a && b) {
       cout << "true: " << endl;
   }
   else 
   {
       cout << "false: " << endl;
   }
   return 0;
}
  • true

  • false

  • error

  • 10

Question 3

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

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


    int a = 12, b = 15, c;
    c = (a > b) ? a : b;
    cout << c;


    return 0;
}


 

  • 7

  • 32

  • 15

  • 23

Question 4

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

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


    int a, b, c;
    a = 3;
    b = 9;
    c = (a > b) ? a : b;
    cout << "c: " << c;


    return 0;
}


 

  • 2

  • 7

  • 9

  • 14

Question 5

Identify the correct example for a pre-increment operator.


 

  • ++n


     

  • n++


     

  •  - -n


     

  • +n


     

Question 6

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

#include <iostream>
   using namespace std;
   int main()
   {
       int a;
       a = 9 + 4 * 2;
       cout << a;
       return 0;
   }
  • 17

  • 19

  • 21

  • 25

Question 7

Which of the following data type will throw an error on modulus operation(%)?

  • char

  • short

  • int

  • float

Question 8

Which of the following is not an arithmetic operation?

  • b * = 10;

  • b / = 10;

  • b ! = 10;

  • a % = 10;

Question 9

What is the precedence of arithmetic operators (from highest to lowest)?

  • %, *, /, +, –

  • %, +, /, *, –

  • +, -, %, *, /

  • %, +, -, *, /

Question 10

Which operator is having the highest precedence in C++?

  • array subscript

  • static_cast

  • Scope resolution operator

  • dynamic_cast

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion