Welcome to your C++ Programming MCQ
1.
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?
2.
What is the purpose of the const keyword in C++?
What is the purpose of the const keyword in C++?
3.
How do you define a constant in C++?
How do you define a constant in C++?
4.
What is the output of cout << 3/2; in C++?
What is the output of cout << 3/2; in C++?
5.
How do you declare an integer variable in C++?
How do you declare an integer variable in C++?
6.
What is the purpose of the cin object in C++?
What is the purpose of the cin object in C++?
7.
How do you pass an array to a function in C++?
How do you pass an array to a function in C++?
8.
What is the purpose of the static keyword in C++?
What is the purpose of the static keyword in C++?
9.
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++?
10.
What is the purpose of #ifndef directive in C++ header files?
What is the purpose of #ifndef directive in C++ header files?
11.
What is the correct way to initialize an array in C++?
What is the correct way to initialize an array in C++?
12.
How do you dynamically allocate memory in C++?
How do you dynamically allocate memory in C++?
13.
How do you access the address of a variable in C++?
How do you access the address of a variable in C++?
14.
What is the purpose of void in function declarations in C++?
What is the purpose of void in function declarations in C++?
15.
What is the purpose of #include directive in C++?
What is the purpose of #include directive in C++?
16.
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?
17.
What is the output of cout << sizeof(int); in C++?
What is the output of cout << sizeof(int); in C++?
18.
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++?
19.
How do you concatenate two strings in C++?
How do you concatenate two strings in C++?
20.
What does the strcmp() function do in C++?
What does the strcmp() function do in C++?
21.
How do you define a class in C++?
How do you define a class in C++?
22.
How do you free dynamically allocated memory in C++?
How do you free dynamically allocated memory in C++?
23.
How do you read a character from the keyboard in C++?
How do you read a character from the keyboard in C++?
24.
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++?
25.
How do you declare a pointer to an integer in C++?
How do you declare a pointer to an integer in C++?
26.
How do you declare a virtual function in C++?
How do you declare a virtual function in C++?
27.
What is the purpose of new in C++?
What is the purpose of new in C++?
28.
How do you declare a pure virtual function in C++?
How do you declare a pure virtual function in C++?
29.
How do you define a multi-dimensional array in C++?
How do you define a multi-dimensional array in C++?
30.
What is the purpose of friend keyword in C++?
What is the purpose of friend keyword in C++?