Welcome to your C++ Programming MCQ
1.
What is the purpose of the const keyword in C++?
What is the purpose of the const keyword in C++?
2.
What is the correct way to initialize an array in C++?
What is the correct way to initialize an array in C++?
3.
How do you write a for loop in C++ that iterates 5 times?
How do you write a for loop in C++ that iterates 5 times?
4.
What is the purpose of new in C++?
What is the purpose of new in C++?
5.
How do you pass an array to a function in C++?
How do you pass an array to a function in C++?
6.
How do you concatenate two strings in C++?
How do you concatenate two strings in C++?
7.
How do you declare a virtual function in C++?
How do you declare a virtual function in C++?
8.
How do you declare a pure virtual function in C++?
How do you declare a pure virtual function in C++?
9.
How do you access the address of a variable in C++?
How do you access the address of a variable in C++?
10.
What is the purpose of the cin object in C++?
What is the purpose of the cin object in C++?
11.
How do you declare a pointer to an integer in C++?
How do you declare a pointer to an integer in C++?
12.
What is the purpose of the break statement in a switch statement in C++?
What is the purpose of the break statement in a switch statement in C++?
13.
How do you open a file named data.txt for writing in C++?
How do you open a file named data.txt for writing in C++?
14.
What does the strcmp() function do in C++?
What does the strcmp() function do in C++?
15.
How do you free dynamically allocated memory in C++?
How do you free dynamically allocated memory in C++?
16.
How do you dynamically allocate memory in C++?
How do you dynamically allocate memory in C++?
17.
How do you access the third element of an array arr in C++?
How do you access the third element of an array arr in C++?
18.
How do you define a multi-dimensional array in C++?
How do you define a multi-dimensional array in C++?
19.
What is the purpose of the static keyword in C++?
What is the purpose of the static keyword in C++?
20.
What is the output of cout << sizeof(int); in C++?
What is the output of cout << sizeof(int); in C++?
21.
What is the purpose of friend keyword in C++?
What is the purpose of friend keyword in C++?
22.
What is the output of cout << 3/2; in C++?
What is the output of cout << 3/2; in C++?
23.
What is the purpose of #include directive in C++?
What is the purpose of #include directive in C++?
24.
What is the purpose of #ifndef directive in C++ header files?
What is the purpose of #ifndef directive in C++ header files?
25.
How do you read a character from the keyboard in C++?
How do you read a character from the keyboard in C++?
26.
What is the output of printf("%p", ptr); in C++, where ptr is a pointer?
What is the output of printf("%p", ptr); in C++, where ptr is a pointer?
27.
How do you declare an integer variable in C++?
How do you declare an integer variable in C++?
28.
How do you define a constant in C++?
How do you define a constant in C++?
29.
What is the purpose of void in function declarations in C++?
What is the purpose of void in function declarations in C++?
30.
How do you define a class in C++?
How do you define a class in C++?