Explore topic-wise MCQs in C++ Programming.

This section includes 44 Mcqs, each offering curated multiple-choice questions to sharpen your C++ Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of this program?
#include 
using namespace std;
int main()
{
int p;
p = 15 + 13 * 6;
cout << p;
return 0;
}

A. 93
B. 15
C. 13
D. 6
E. None of these
Answer» B. 15
2.

What is the output of this program?
#include 
using namespace std;
int main()
{
int p = 7, q = 9, r;
r = (p > q) ? p : q;
cout << r;
return 0;
}

A. 7
B. 9
C. Compilation Error
D. Runtime Error
E. None of these
Answer» C. Compilation Error
3.

What is the output of this program?
#include 
using namespace std;
int main ()
{
int p, q;
p = 6;
q = ++p * ++p;
cout << p< p = 6;
q = p++ * ++p;
cout < return 0;
}

A. 8 64
B. 8 48
C. 64 8 48
D. 8 64 8 48
E. None of these
Answer» E. None of these
4.

What is the output of this program?
#include 
using namespace std;
class Example
{
public:
int m, n;
Example() {};
Example(int, int);
Example operator + (Example);
};
Example::Example (int p, int q)
{
m = p;
n = q;
}
Example Example::operator+ (Example parameter)
{
Example container;
container.m = m + parameter.m;
container.n = n + parameter.n;
return (container);
}
int main ()
{
Example p (3,4);
Example q (6,5);
Example R;
R = p + q;
cout << R.m << "," << R.n;
return 0;
}

A. 9,9
B. 3,4
C. 6,5
D. Compilation Error
E. None of these
Answer» B. 3,4
5.

What is the output of this program?
#include 
using namespace std;
void Add(int p, int q, int & r)
{
p = q + r;
p = q + r;
r = p + q;
}
int main()
{
int n = 6, m =4;
Add(n, m, m);
cout << n << " " << m;
return 0;
}

A. 6 12
B. 6
C. 12
D. 6 4
E. 12 6
Answer» B. 6
6.

What is the output of this program?
#include 
using namespace std;
ostream & operator< {
return k;
}
int main()
{
cout << 10 << endl;
cin.get();
return 0;
}

A. 10
B. Compilation Error
C. Runtime Error
D. Garbage Value
E. None of these
Answer» C. Runtime Error
7.

What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
class Example
{
public:
operator string ()
{
return "Converted...";
}
};
int main()
{
Example examp;
string str = examp;
cout << str << endl;
return 0;
}

A. Compilation Error
B. Runtime Error
C. Converted...
D. Garbage value
E. None of these
Answer» D. Garbage value
8.

What is the output of this program?
#include <iostream>
#include <cmath>
using namespace std;
class ComplexNumber
{
private:
double RealNumber;
double ImagNumber;
public:
ComplexNumber(double r = 0.0, double i = 0.0) : RealNumber(r), ImagNumber(i)
{}
double mag()
{
return getMag();
}
operator double ()
{
return getMag();
}
private:
double getMag()
{
return sqrt(RealNumber * RealNumber + ImagNumber * ImagNumber);
}
};
int main()
{
ComplexNumber comp(2.0, 5.0);
cout << comp.mag()< cout << comp;
return 0;
}

A. 2.0
B. 5.0
C. 5.38516
D. 5.38516 5.38516
E. None of these
Answer» E. None of these
9.

What is the output of this program?
#include <iostream>
using namespace std;
class Example
{
public:
Example(int k) : num_k(k) { }
public:
int operator()(int k = 0) const
{
return num_k + k;
}
operator int () const
{
return num_k;
}
private:
int num_k;
friend int g(const Example&);
};
int fun(char Z)
{
return Z;
}
int main()
{
Example fun(6);
cout << fun(5);
return 0;
}

A. 6
B. 5
C. 11
D. Compilation Error
E. None of these
Answer» D. Compilation Error
10.

What is the output of this program?
#include 
using namespace std;
main()
{
double num = 23.9399;
float num0 = 20.23;
int p ,q;
p = (int) num;
q = (int) num0;
cout << p < return 0;
}

A. 20 23
B. 23.9399
C. 20.23
D. 23 20
E. None of these
Answer» E. None of these
11.

What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int Number1 = 7;
int Number2 = 5;
if ( Number1 && Number2 )
{
cout << "True"<< endl ;
}
else
{
cout << "False"<< endl ;
}
return 0;
}

A. Compilation Error
B. False
C. Runtime Error
D. True
E. None of these
Answer» E. None of these
12.

What is the output of this program?
#include <iostream>
using namespace std;
int main ()
{
int p, q, R;
p = 5;
q = 3;
R = (p > q) ? p : q;
cout << R;
return 0;
}

A. 3
B. Compilation Error
C. Runtime Error
D. Garbage value
E. 5
Answer» F.
13.

What is the output of this program?
#include <iostream>
using namespace std;
int main ()
{
int num1, num2;
num1 = 6;
num2 = 5;
num1 = num2;
num2 = 3;
cout << "num1:";
cout << num1;
cout << ", num2:";
cout << num2;
return 0;
}

A. num1: 5, num2: 3
B. num1: 3, num2: 5
C. num1: 6, num2: 5
D. Compilation Error
E. None of these
Answer» B. num1: 3, num2: 5
14.

What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int p = 5;
int q = 15;
int r = 35;
int s = 7;
int Res;
Res = p + q * r / s;
cout << Res << endl ;
return 0;
}

A. 5
B. 15
C. 35
D. 7
E. 80
Answer» F.
15.

What is the output of this program?
#include <iostream&f=gt;
using namespace std;
class Num
{
private:
int Values[15];
public:
int& operator[] (const int Val);
};
int& Num::operator[](const int Val)
{
return Values[Val];
}
int main()
{
Num Object;
Object[10] = 6;
cout << Object[10];
return 0;
}

A. 15
B. 10
C. 6
D. Compilation Error
E. None of these
Answer» D. Compilation Error
16.

What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
double P = 12.93099;
float Q = 11.120;
int R ;
R = (int) P;
cout << R < R = (int) Q;
cout << R ;
return 0;
}

A. 12.93099 11.120
B. 11.120 12.93099
C. 11 12
D. 12 11
E. None of these
Answer» E. None of these
17.

What is the output of this program?
#include <iostream> 
using namespace std;
int main()
{
int num1 = 10, num2 = 12;
cout << ++num1 < return 0;
}

A. 10 12
B. 12 10
C. 11 11
D. Compilation Error
E. None of these
Answer» D. Compilation Error
18.

What is the output of this program?
#include <iostream> 
using namespace std;
int main()
{
int num = 15;
int Res ;
Res = num++;
cout << Res;
return 0;
}

A. 16
B. 15
C. 14
D. Compilation Error
E. None of these
Answer» C. 14
19.

What is the output of this program?
#include <iostream>
using namespace std;
class Example
{
private:
int* K;
int L;
public:
Example (int L);
~Example ();
int& operator [] (int num);
};
int& Example::operator [] (int num)
{
return K[num];
}
Example::Example (int L)
{
K = new int [L];
L = L;
}
Example::~Example ()
{
delete [] K;
}
int main ()
{
Example obj (10);
obj [0] = 15;
obj [1] = 10;
obj [2] = 35;
obj [3] = 30;
for (int num = 0; num < 5; ++ num)
cout << obj [num] < return 0;
}

A. 15 10 0 30 35
B. 35 30 15 10 0
C. 0 10 15 30 35
D. 0 15 10 35 30
E. 15 10 35 30 0
Answer» F.
20.

What is the output of this program?
#include <iostream> 
using namespace std;
class Example
{
public:
int p;
Example(int num = 0) : p(num) {};
int& operator[](int num)
{
cout << "Interview " ;
return p;
}
int operator[](int num) const
{
cout << "Mania" ;
return p;
}
};
void foo(const Example& n)
{
int Res = n[2];
}
int main()
{
Example n(7);
n[3] = 8;
int Res = n[2];
foo(n);
return 0;
}

A. Interview Interview Mania
B. Interview Mania
C. Mania
D. Compilation Error
E. None of these
Answer» B. Interview Mania
21.

What is the output of this program?
#include 
using namespace std;
int main()
{
int K, L;
L = 12;
K = (L++, L + 105, 99 + L);
cout << K;
return 0;
}

A. 105
B. 99
C. 12
D. 1010
E. 112
Answer» F.
22.

What is the output of this program?
#include 
using namespace std;
int main()
{
int p = 7, q = 9, r, s;
r = p, q;
s = (p, q);
cout << r << ' ' << s;
return 0;
}

A. 7 9
B. 9 7
C. 9
D. 7
E. None of these
Answer» B. 9 7
23.

What is the output of this program?
#include <iostream> 
using namespace std;
int main()
{
int num1 = 7;
int num2 = 4;
int num3 = 6;
num1 = num2++;
num2 = --num3;
cout << num1 < return 0;
}

A. 5 4 5
B. 5 5 4
C. 4 5 5
D. Compilation Error
E. None of these
Answer» D. Compilation Error
24.

What is the output of this program?
#include <iostream> 
using namespace std;
int main()
{
int num1 = 7, num2 = 3, Res;
num1 = ++num1;
num2 = --num2;
Res = num1 + ++num1;
cout << Res;
return 0;
}

A. 7
B. 3
C. 17
D. 18
E. None of these
Answer» E. None of these
25.

Which concepts does the Pre Increment use?

A. queue
B. call by value
C. call by reference
D. All of above
E. None of these
Answer» D. All of above
26.

How many types are there in increment/decrement operator?

A. 4
B. 3
C. 2
D. 1
E. None of these
Answer» D. 1
27.

Which operator works only with integer variables?

A. modulus
B. decrement
C. increment
D. both decrement & increment
E. None of these
Answer» E. None of these
28.

What do we need to use when we have multiple subscripts?

A. operator
B. operator()
C. operator[].
D. All of above
E. None of these
Answer» C. operator[].
29.

What do we need to do to pointer for overloading the subscript operator?

A. store it in heap
B. reference pointer
C. dereference pointer
D. All of above
E. None of these
Answer» D. All of above
30.

subscript operator is used to access which elements?

A. char
B. array
C. string
D. All of above
E. None of these
Answer» C. string
31.

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

A. dynamic_cast
B. static_cast
C. array subscript
D. Scope resolution operator
E. None of these
Answer» E. None of these
32.

What is the name of | operator?

A. or
B. and
C. modulus
D. sizeof
E. None of these
Answer» B. and
33.

What is the associativity of add(+);

A. left to right
B. Top to bottom
C. right to left
D. both Top to bottom & right to left
E. None of these
Answer» B. Top to bottom
34.

Pick out the compound assignment statement.

A. p = p / q
B. p -= 6
C. p = p 6
D. All of above
E. None of these
Answer» C. p = p 6
35.

In which direction does the assignment operation will take place?

A. top to bottom
B. left to right
C. right to left
D. All of above
E. None of these
Answer» D. All of above
36.

What are the essential operators in c++?

A. <=
B. +
C. |
D. All of above
E. None of these
Answer» E. None of these
37.

Pick out the correct syntax of operator conversion.

A. operator float()
B. operator const
C. operator float()const
D. All of above
E. None of these
Answer» D. All of above
38.

How are types therein user-defined conversion?

A. 4
B. 3
C. 2
D. 1
E. None of these
Answer» D. 1
39.

How many parameters does a conversion operator may take?

A. as many as possible
B. 3
C. 2
D. 1
Answer» F.
40.

Why we use the dynamic_cast type conversion?

A. to be used in low memory
B. result of the type conversion is an invalid
C. result of the type conversion is a valid
D. All of above
E. None of these
Answer» D. All of above
41.

What is the return type of the conversion operator?

A. no return type
B. float
C. int
D. void
E. None of these
Answer» B. float
42.

Operator overloading is

A. adding operation to the existing operators
B. making the new operator
C. making c++ operator works with objects
D. giving new meaning to existing operator
E. None of these
Answer» B. making the new operator
43.

Which of the following operators can t be overloaded?

A. [].
B.
C. +
D. ::
E. None of these
Answer» E. None of these
44.

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

A. Type cast
B. Function call
C. Function call
D. Array subscripting
E. None of these
Answer» B. Function call