If 'ptr' points to the first element of an array, what does 'ptr + 1' point to?
The size of the array
The address of the array itself
The previous element in the array
The next element in the array
What is a pure virtual function in C++?
A function that can be called before an object is created
A function that creates new data types
A function with no implementation in the base class, meant to be overridden by derived classes
A function that automatically destroys an object
What will the following code snippet print?
int num = 10; while (num > 0) { num = num - 2; cout << num << " "; }
10 8 6 4 2 0
8 6 4 2 0
10 8 6 4 2
9 7 5 3 1
What is a function signature in C++?
The comments and documentation associated with a function.
The value returned by the function.
The function's body (the code within the curly braces).
The function's name and the data types of its parameters.
What is the correct way to declare an integer array named 'numbers' with a size of 5 in C++?
int numbers(5);
int numbers[5];
array numbers[5];
numbers[5] as int;
How do you declare a multi-dimensional array (specifically, a 2D array) in C++?
int matrix[3, 4];
array matrix[3, 4];
int matrix(3)(4);
int matrix[3][4];
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
5
Compilation Error
15
Which of the following is NOT a valid way to initialize a character array in C++?
char message[10] = {'H', 'e', 'l', 'l', 'o'};
char message[] = "Hello";
char message[5] = "Hello";
char message[10] = "Hello";
Which statement is used to display output to the console in C++?
cout
printf
print
cin
Which of the following loops in C++ guarantees that the loop body will execute at least once?
do-while loop
None of the above
for loop
while loop