Which of the following is NOT a type of inheritance in C++?
Multilevel inheritance
Distributed inheritance
Multiple inheritance
Single inheritance
If 'func' is a function that takes an integer and returns void, how would you call this function using a pointer 'ptr' to the function?
func(ptr, 5);
ptr(5);
*ptr(5);
&ptr(5);
What is the correct syntax to declare a pointer variable named 'ptr' that points to an integer?
int &ptr;
ptr int;
*int ptr;
int *ptr;
Which of the following loops in C++ guarantees that the loop body will execute at least once?
while loop
for loop
None of the above
do-while loop
How do you declare a multi-dimensional array (specifically, a 2D array) in C++?
array matrix[3, 4];
int matrix[3][4];
int matrix(3)(4);
int matrix[3, 4];
What is the correct way to declare a constant variable named 'PI' with the value 3.14159?
constant PI = 3.14159;
#define PI = 3.14159
const float PI 3.14159;
const float PI = 3.14159;
What is the value of 'i' after the following loop completes?
int i; for (i = 0; i < 5; i++) { // Loop body }
Undefined behavior
4
5
6
What is the output of the following C++ code snippet?
#include <iostream> int main() { int x = 5; int y = 10; int result = (x, y); std::cout << result; return 0; }
10
Compilation Error
15
What is the output of the following code snippet: cout << (5 > 3 && 10 < 20);?
cout << (5 > 3 && 10 < 20);
0
3
1
If 'ptr' is a pointer to an integer variable 'num', how would you access the value stored in 'num' using 'ptr'?
*ptr
ptr
&ptr
num