What does the modulus operator (%) return?
The product of two operands.
The sum of two operands.
The remainder of a division.
The quotient of a division.
Why are pointers particularly useful when working with dynamic memory allocation?
Pointers make our code run faster because they are low-level.
Pointers are required by the C++ syntax for dynamic memory allocation.
Pointers help us avoid using loops and conditional statements.
Pointers allow us to directly access and manipulate memory addresses.
What is an inline function in C++?
A function that is declared with the 'inline' keyword, which serves as a request to the compiler to replace the function call with its actual code.
A function that is defined inside another function.
A function that takes another function as a parameter.
A function that does not return any value.
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?
ptr(5);
func(ptr, 5);
*ptr(5);
&ptr(5);
Which operator is used to combine two strings in C++?
/
What is the purpose of the 'break' statement in a switch-case statement?
To exit the switch-case statement
To repeat the current case statement
To jump to a specific case statement
To skip to the next case statement
What is a pure virtual function in C++?
A function that creates new data types
A function that can be called before an object is created
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 << " "; }
8 6 4 2 0
10 8 6 4 2
10 8 6 4 2 0
9 7 5 3 1
What is the correct way to declare a constant variable named 'PI' with the value 3.14159?
const float PI = 3.14159;
#define PI = 3.14159
const float PI 3.14159;
constant PI = 3.14159;
What is the primary purpose of a constructor in a C++ class?
To implement polymorphism
To initialize object members when an object is created
To define the class's interface
To free up memory when an object is destroyed