Loops
Understanding and using while in C++
Name: Mohana Helal Almuqati
Student ID:214371630
Eng. Ibrahim Aladini
Loops definition
O These are used to repeat a block of code.
It is the ability to have a program execute
a block of code many times.
Loops Types
O While loop.
O For loop.
O Do..while loop.
O Nested loops.
While loop
O It repeats a statement or multi statements
as long as the condition is true.
O Here is the syntax of a while loop:
Flow Chart (While Loop)
The point is that if the while loop
condition
Is tested as false. The program will skip
to the end. However, if it’s true, the
condition will repeat until the condition is
met.
Ex: Multiplication table using
while loop (5)
Ex: Multiplication table using
while loop (5)
So, The program will start multiplying on (5):
1x5=? 6x5=? 11x5=?
2x5= ? 7x5=? 12x5=?
3x5=? 8x5=?
4x5=? 9x5=?
5x5=? 10x5=?
References:
O http://www.cprogramming.com/tutorial/less
on3.html
O https://www.tutorialspoint.com/cplusplus/c
pp_loop_types.htm
O https://www.tutorialspoint.com/cplusplus/c
pp_while_loop.htm
O http://cpp.sh/5nqe

Understanding and using while in c++