title: mar 2310:49 am (1 of 15)cisweb.bristolcc.edu/.../cis120/c120mar2317.pdf · introduction to...

Post on 02-Oct-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Title: Mar 23­10:49 AM (1 of 15)

Three things you need to code to make aneffective loop:

Would be best to define ans as a var but since I did not when I add ct to ct and assign it to ans, the browser figures out I need a var ans and makes it for me.

Title: Mar 23­11:08 AM (2 of 15)

Title: Mar 23­11:20 AM (3 of 15)

Title: Mar 23­11:26 AM (4 of 15)

Remember with the do...while the check of thecontrol is at the bottom. When the check is atthe bottom, the loop gets executed once beforethe check.

Title: Mar 23­11:30 AM (5 of 15)

This works the same as the while that wewent through.

Title: Mar 23­11:31 AM (6 of 15)

Note the definition ofvar i is not needed since it is done in thefor loop.

Title: Mar 23­11:33 AM (7 of 15)

Title: Mar 23­11:34 AM (8 of 15)

Title: Mar 23­11:37 AM (9 of 15)

Title: Mar 23­11:43 AM (10 of 15)

Title: Mar 23­11:48 AM (11 of 15)

Title: Mar 23­11:50 AM (12 of 15)

Note that I need the promptbetween the while checks.

Title: Mar 23­11:57 AM (13 of 15)

Homework ­ check for assignment

Title: Mar 23­11:58 AM (14 of 15)

To approaches ­ one thatassumes the user willonly enter 1,2 or 3 andone that checks forentering something else

Title: Mar 23­12:09 PM (15 of 15)

top related