Which type of loop is best suited when the number of iterations is known ahead of time?
- do-while loop
- while loop
- for loop
- recursive function
A for loop is best suited when the number of iterations is known ahead of time, as it allows for an initial statement (typically for initialization), a condition check, and an increment/decrement operation in a compact syntax.
Loading...
Related Quiz
- If an exception is thrown and not caught anywhere in the program, function _______ is called.
- The _______ operator is used to compare whether two C++ values are not equal.
- What is the use of a catch block with an ellipsis (...)?
- In which year was the C++98 standard officially published?
- In C++20, using enum with _______ allows specifying the underlying type and scope.