What does the modulus operator (%) return?
The quotient of a division.
The remainder of a division.
The product of two operands.
The sum of two operands.
What is the output of the following code snippet?
int arr[] = {10, 20, 30}; int *ptr = arr; cout << *(ptr + 2);
Invalid memory access
20
30
10
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 next element in the array
The previous element in the array
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);
Which of these is NOT a benefit of using functions in programming?
Improved code organization
Easier debugging and maintenance
Code reusability
Increased memory usage
Which loop is most suitable when you know the number of iterations in advance?
for loop
while loop
do-while loop
It depends on the specific situation.
How do you declare a variable named 'age' of integer type?
age as int;
variable age: int;
declare age as integer;
int age;
How do you declare a multi-dimensional array (specifically, a 2D array) in C++?
int matrix(3)(4);
int matrix[3, 4];
array matrix[3, 4];
int matrix[3][4];
What will the following C++ code snippet print?
#include <iostream> void changeValue(int x) { x = 100; } int main() { int num = 50; changeValue(num); std::cout << num; return 0; }
0
None of the above
50
100
What is the correct way to declare an integer array named 'numbers' with a size of 5 in C++?
array numbers[5];
int numbers(5);
numbers[5] as int;
int numbers[5];