Lecture 7
8
for and while
•for loop better than while loop
–fewer lines
–control all on one line at top of loop
–elegant, idiomatic
–natural when loop count known in advance
•while loop better than for loop
–reads more like pseudocode (English)
–natural when loop count not known in advance (set somehow in body)
•