How do you declare a variable named 'age' of integer type?
age as int;
declare age as integer;
variable age: int;
int age;
What is the value of 'i' after the following loop completes?
int i; for (i = 0; i < 5; i++) { // Loop body }
Undefined behavior
6
5
4
Why are pointers particularly useful when working with dynamic memory allocation?
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.
Pointers make our code run faster because they are low-level.
What is the purpose of the 'return' statement in a C++ function?
It terminates the function's execution and returns control to the calling function.
It marks a section of code for debugging purposes.
It declares a new variable within the function.
It prints the function's output to the console.
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; }
Compilation Error
15
10
Which of the following loops in C++ guarantees that the loop body will execute at least once?
do-while loop
while loop
for loop
None of the above
Which statement is used to skip the rest of the current iteration in a loop and jump to the next iteration?
break
continue
skip
goto
What is the correct way to declare a constant variable named 'PI' with the value 3.14159?
#define PI = 3.14159
constant PI = 3.14159;
const float PI 3.14159;
const float PI = 3.14159;
What is the correct way to declare a multi-line comment in C++?
// This is a multi-line comment
' This is a multi-line comment '
/* This is a multi-line comment */
What is the correct syntax to declare a pointer variable named 'ptr' that points to an integer?
*int ptr;
int &ptr;
ptr int;
int *ptr;