C++ TutorialLesson 16Free preview
C++ While Loop
This lesson is part of C++ · All levels
Summary
This lesson discusses the repetition while that executes a block of code during a value condition. It is suitable for use when the number of repetitions is not known at the beginning, for example reading the input until the user presses a certain number. You also learn to keep the loop running without limits.
Key points
- While executing blocks while the conditions are met.
- The control variable must be updated to allow the loop to reach a stop point.
- Blocks are not executed at all when the initial condition is already present.
- Common mistake: forget the increment so that there is an infinite loop.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.