While Loops
While Loops
Iteration
Lecture
While Loops
Module 10 Learning Objectives
Last time, we finished our discussion of for and
foreach loops
This time, well look at while loops, which give us
a way to iterate when we dont know how many
times well need to iterate
In-Lecture Quiz
The loop well use to perform iteration in our C# code
when we dont know how many times to loop is the
A: while loop
B: if loop
C: Hula Loop
D: loopInC# statement
In-Lecture Quiz
An infinite loop occurs when we
A: loop infinitely (duh)
B: let our computer run until the end of time
C: dont change anything in the body of the loop to
affect the test
D: use < instead of <= in our Boolean expression
In-Lecture Quiz
We can avoid lots of loop problems by thinking about ITM,
which means
A: I Taste Monkeys
B: Incas Toast Men
C: Initialize Test Modify
D: Are you (*&%#*# kidding me?
In-Lecture Quiz
When we test a while loop we should execute the loop body
A: 0, 1, and multiple times
B: with C4 and a grapefruit
C: with a sledgehammer and a melon
D: Why? Just why?
Recap
We learned how we can use while loops when we
dont know how many times well need to iterate
End of Module 10
Next Time
Well start working on designing and implementing
our own custom classes