ECE 152 Lec 4 Notes
Repetition or Loop
o In programming, sometimes we may want to execute a set of statements
repeatedly.
o For example:
Displaying each student’s score in a test
Computing and displaying each employee’s weekly salary
o For that purpose, we use while, do-while, and for loop statements in our
programs
The while statement
o Boolean expression is evaluated the same as in if-else expression
Statements inside the while block will be executed repeatedly as long as
the Boolean expression has a true value