Coding 101: The While Loop
No matter what programming language you start to code in, it is important that you understand the basics to start and build from there. One of the core functionalities in programming that is used throughout every object-oriented programming language is the “while” loop.
This article will:
- Define what a while loop is
- Breakdown the structure of a while loop
- Show the different comparisons that can be used in a while loop
- Show how it is used in code
What is a while statement?
A while statement is a control flow statement in code that tells your program to repeat a section of code until a certain criterion is met. In English, sometimes you may want to repeat a certain action until the desired result is met. An example of this could be you want to walk a mile a day until you lose 10 pounds. Once you lose 10 pounds you no longer want to walk a mile every day. You will keep repeating the action of walking until the criteria is met of you losing 10 pounds.