0% found this document useful (0 votes)
30 views1 page

What Is The While Loop

A while loop repeats a block of code as long as a condition is true. It first evaluates the condition and if true, runs the code block before re-evaluating. In C++, a while loop uses the while keyword followed by a boolean condition and colon, with the code block indented below.

Uploaded by

ubichgab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views1 page

What Is The While Loop

A while loop repeats a block of code as long as a condition is true. It first evaluates the condition and if true, runs the code block before re-evaluating. In C++, a while loop uses the while keyword followed by a boolean condition and colon, with the code block indented below.

Uploaded by

ubichgab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

What is the while loop?

A "While" Loop is used to repeat a specific block of code an unknown number of times, until a
condition is met. For example, if we want to ask a user for a number between 1 and 10, we don't know
how many times the user may enter a larger number, so we keep asking "while the number is not
between 1 and 10".
In most computer programming languages, a do while loop is a control flow statement that
executes a block of code and then either repeats the block or exits the loop depending on a given
boolean condition.
What is the while loop in C++?
The while loop C++ is a type of loop that will first evaluate a condition. If the condition is true,
the program will run the code inside of the while loop. It will then go back and re-evaluate the
condition. Every time the condition is true, the program will perform the code inside the loop.
Let's break it down:
You start the while loop by using the while keyword.
Then, you add a condition which will be a Boolean expression. ...
The condition is followed by a colon, : .
On a new line, you add a level of indentation. ...
Then, the code you want to run goes in the body of the while statement.

You might also like