Lecture 4: Loops
Optional reading: chapter 5.
while and do while loops
Key ideas:
- loop control variable
- accumulator variables
- compound assignment statements (
+=,-=,*=,/=,%=) ++avs.a++whilevs.do while
for loops
Key ideas:
- when to use
forvs.while: when stopping point is known vs. not forloops are just more compactly writtenwhileloops- nested loops