A ______ statement can be used as a control structure to repeatedly execute a block of code as long as a particular condition remains true.

  • For
  • If
  • Switch
  • While
In programming, a "while" statement is a control structure that creates a loop. It repeatedly executes a block of code as long as a specified condition remains true. This is useful for scenarios where you want to perform an action multiple times until a certain condition is met.

A common mistake that leads to infinite loops is forgetting to update the ______ variable.

  • Counter
  • Loop
  • Control
  • Iterator
A common mistake that leads to infinite loops is forgetting to update the 'Counter' variable. In loops, the counter variable is crucial for controlling the loop's progress and termination.

In nested loops, if a break statement is executed inside the inner loop, the control will exit the ______ loop.

  • Inner
  • Outer
  • Both inner and outer
  • None of the above
In nested loops, a break statement is used to exit the innermost loop. When it's executed, control exits the inner loop, not the outer one. Therefore, the correct option is 'Inner.'

Which C++ statement is used to make a single conditional decision?

  • for loop
  • if statement
  • switch statement
  • while loop
The 'if' statement in C++ is used to make a single conditional decision. It allows you to execute a block of code only if a specified condition is true. This is fundamental for controlling the flow of your program based on conditions.

If you have multiple conditions, which statement can be used to test multiple conditions sequentially?

  • do-while loop
  • for loop
  • if-else statement
  • switch statement
The 'if-else' statement in C++ is used when you have multiple conditions to test sequentially. It allows you to define different blocks of code to execute for different conditions, providing a structured way to handle multiple possibilities.

Maria wrote a function that has a default argument. She noticed that sometimes it uses the default value, while other times it uses the value she provides. What could be the possible reason for this behavior?

  • Compilation Error
  • Compiler Optimization
  • Incorrect Function Call
  • Incorrect Function Definition
The possible reason for Maria's function sometimes using the default value and other times using the value she provides is an Incorrect Function Call. If she calls the function without providing an argument for the parameter with the default value, it will use the default value. However, if she explicitly provides an argument, the provided value will be used.

When a function is called recursively for a purpose other than for a placeholder purpose, it's termed as ______ recursion.

  • Direct
  • Head
  • Indirect
  • Tail
When a function calls itself as its last operation before returning, it's called 'tail recursion.' Tail recursion is often optimized by compilers, making it an efficient way to implement certain algorithms, like calculating factorials or traversing data structures.

How does the compiler handle the default value of a function argument if it's not provided in a function call?

  • It assigns a random value
  • It assigns a value of 0
  • It assigns the default value specified in the function declaration
  • It raises a compilation error
It assigns the default value specified in the function declaration. When a function argument with a default value is not provided in a function call, the compiler assigns the value specified in the function's declaration. This behavior ensures that functions can be called with missing arguments.

Robert notices that in a certain switch-case structure in his program, two different cases seem to execute sequentially without a break. What could be the reason behind this behavior?

  • Compiler error
  • Improper case order
  • Incorrect switch statement
  • Missing break statements
The reason behind two different cases executing sequentially without a break is most likely missing break statements within the cases. In a switch-case structure, if a break statement is omitted, execution will "fall through" to the next case. Robert should ensure that each case has the appropriate break statement to exit the switch statement after execution.

When you need to store an integer without any sign (only positive), you should use ______ data types.

  • long
  • short
  • signed
  • unsigned
In C++, the unsigned data type is used to store integers without any sign, which means they can only represent positive values or zero. This is useful when you need to work with quantities that should not have negative values, like the number of items in a collection.