Loading...

C++ Multiple Choice Questions

Our C++ questions and answers focuses on all areas of C++ programming language covering 100+ topics in C++

C++ Operators MCQ | Set 1

C++ Operators | Set 1


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

a) Array subscripting
b) Function call
c) Addition and subtraction
d) Type cast



2. What are the essential operators in c++?

a) +
b) |
c) <=
d) All of the mentioned



3. In which direction does the assignment operation will take place?

a) left to right
b) right to left
c) top to bottom
d) bottom to top



4. Pick out the compound assignment statement.

a) a = a – 5
b) a = a / b
c) a -= 5
d) a = a + 5



5. 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;
}

a) a:4 b:7
b) a:10 b:4
c) a:4 b:10
d) a:4 b:6



6. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {

    int a, b, c;
    a = 2;
    b = 7;
    c = (a > b) ? a : b;
    cout << "c: " << c;

    return 0;
}

a) 2
b) 7
c) 9
d) 14



7. 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;
}

a) true
b) false
c) error
d) 10



8. What is the associativity of add(+); ?

a) right to left
b) left to right
c) right to left & left to right
d) top to bottom



9. What is the name of | operator?

a) sizeof
b) or
c) and
d) modulus



10. Which operator is having the highest precedence in c++?

a) array subscript
b) Scope resolution operator
c) static_cast
d) dynamic_cast



- Related Topics