Which loop in C++ tests the condition before executing its body?
- do-while loop
- for loop
- switch loop
- while loop
The while loop in C++ tests the condition before executing its body. It's a pre-test loop, meaning that it evaluates the condition first, and if it's true, it enters the loop body. This loop is suitable when you want to execute a block of code as long as a condition is true initially.
Loading...
Related Quiz
- What will be the output of a while loop if its condition is initially false?
- When a continue statement is encountered in a loop, the program control resumes from _______.
- What is the primary benefit of using class templates in C++?
- Which of the following data types can store a non-integer number?
- When declaring a function, which keyword is used to specify that the function should have a default argument?