Which data type is used to store whole numbers without any decimal points?
double
string
float
int
What is the output of the following code snippet?
int i = 10; do { cout << i << " "; i--; } while (i > 10);
10 9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1 0
The loop will run infinitely
10
Which of the following loops in C++ guarantees that the loop body will execute at least once?
do-while loop
None of the above
while loop
for loop
What is an inline function in C++?
A function that does not return any value.
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.
Which statement is used to skip the rest of the current iteration in a loop and jump to the next iteration?
goto
skip
break
continue
What does the 'protected' access specifier in C++ control?
Accessibility within the same class and derived classes
Accessibility only within the same file
Accessibility from anywhere in the program
Accessibility within the same class only
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
5
What is the value of 'i' after the following loop completes?
int i; for (i = 0; i < 5; i++) { // Loop body }
6
Undefined behavior
4
Which loop is most suitable when you know the number of iterations in advance?
It depends on the specific situation.
What C++ function can you use to find the length of a C-style string (character array)?
str_length()
size()
strlen()
length()