Which of these is NOT a benefit of using functions in programming?
Easier debugging and maintenance
Code reusability
Improved code organization
Increased memory usage
What is the output of the following code snippet?
int i = 10; do { cout << i << " "; i--; } while (i > 10);
The loop will run infinitely
10 9 8 7 6 5 4 3 2 1
10
9 8 7 6 5 4 3 2 1 0
In a switch-case statement, what happens if no case matches the switch expression and there is no 'default' case?
The behavior is undefined.
The program enters an infinite loop.
A compilation error occurs.
The switch-case statement is skipped.
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
50
100
None of the above
If 'ptr' points to the first element of an array, what does 'ptr + 1' point to?
The previous element in the array
The next element in the array
The size of the array
The address of the array itself
Which data type is used to store whole numbers without any decimal points?
string
int
double
float
Which loop is most suitable when you know the number of iterations in advance?
do-while loop
It depends on the specific situation.
while loop
for loop
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 statement is used to skip the rest of the current iteration in a loop and jump to the next iteration?
goto
break
continue
skip
Can a function in C++ return multiple values?
Yes, using multiple 'return' statements.
No, a C++ function can only return a single value.
Yes, by returning a container like a vector or an array.
Yes, by using references or pointers as parameters.