Explore topic-wise MCQs in C++ Programming.

This section includes 12 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;
namespace One
{
int num = 12;
}
namespace Two
{
double num = 10.027;
}
int main ()
{
int n;
n = One::num + Two::num;
cout << n;
return 0;
}

A. 22
B. 12
C. 10.027
D. 22.027
E. None of these
Answer» B. 12
2.

What is the output of this program?
#include 
using namespace std;
namespace calculation
{
int p;
}
void p()
{
using namespace calculation;
int p;
p = 15;
cout << p;
}
int main()
{
enum letter { K, L};
class K { letter L; };
::p();
return 0;
}

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

What is the output of this program?
#include 
using namespace std;
namespace calc
{
int p = 12;
}
namespace calc
{
int q = 23;
}
int main(int argc, char * argv[])
{
calc::p = calc::q =6;
cout << calc::p << calc::q;
}

A. 66
B. 12
C. 23
D. 6
E. None of these
Answer» B. 12
4.

What is the output of this program?
#include 
using namespace std;
namespace first
{
int num = 5;
}
namespace second
{
int num = 11;
}
int main ()
{
int num = 27;
first::num;
second::num;
cout << num;
return 0;
}

A. 27
B. 11
C. 25
D. Compilation Error
E. None of these
Answer» B. 11
5.

What is the output of this program?
#include 
using namespace std;
namespace One
{
int K = 15;
int L = 11;
}
namespace Two
{
double K = 4.016;
double L = 7.6001;
}
int main ()
{
using One::K;
using Two::L;
bool p, q;
p = K > L;
q = One::K < Two::L;
cout << p < return 0;
}

A. 15 11
B. 11 15
C. 4 7
D. 7 4
E. 1 0
Answer» F.
6.

Which operator is used to signify the namespace?

A. scope operator
B. conditional operator
C. ternary operator
D. All of above
E. None of these
Answer» B. conditional operator
7.

What is the ability to group some lines of code that can be included in the program?

A. modularization
B. program control
C. macros
D. specific task
E. None of these
Answer» B. program control
8.

How many types do functions call depends on modularization?

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

Which of the following implements the module in the program?

A. method
B. macro
C. header files
D. macro & header files
E. None of these
Answer» D. macro & header files
10.

What is similar to the interface in c++

A. pure abstract class
B. instance of a class
C. methods
D. All of above
E. None of these
Answer» B. instance of a class
11.

What does the client module import?

A. interface
B. records
C. macro
D. All of above
E. None of these
Answer» B. records
12.

Which keyword is used to access the variable in the namespace?

A. static
B. const
C. dynamic
D. using
E. None of these
Answer» E. None of these