Lecture 4 - Loops
Lecture 4 - Loops
While Loops
Decision Making
A loop statement allows to repeatedly execute a
statement or group of statements.
A while loop statement repeatedly executes a
target statement as long as a given condition is
true.
Example
The while loops check for the condition
x > 0. If it evaluates to true, it
executes the statements within its
body. Then it checks the statement
again and repeats.
Another loop structure is the for loop, which
allows writing of a loop that needs to execute a
specific number of times.
Example
Syntax: