loops - gorskicompsci.cagorskicompsci.ca/ics2o/unit3/ppt1_loops.pdf · once upon a time there was a...

Post on 26-May-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

LoopsRepetition

Your grade 3 teacher may have read this

book to you.

If they didn’t, I recommend

that you look it up some time.

Without loops, you need to repeat the same step

over and over.

With loops,

the code is more elegant.

Count is the loop stopping variable.

It starts at 0 and stops before it

gets to 5.

The Parts of a Loop

This is on the test and it is on

the exam.

A. Initialize Loop Stopping Variable

The Parts of a Loop

A

A. Initialize Loop Stopping Variable

B. Test Loop Stopping Condition

The Parts of a Loop

A B

A. Initialize Loop Stopping Variable

C. Steps to repeat

B. Test Loop Stopping Condition

The Parts of a Loop

A B

C

A. Initialize Loop Stopping Variable

C. Steps to repeat

B. Test Loop Stopping Condition

D. Progress to the Loop Stopping Condition

The Parts of a Loop

A B

C

D

A. Initialize Loop Stopping Variable

C. Steps to repeat

B. Test Loop Stopping Condition

D. Progress to the Loop Stopping Condition

The Parts of a Loop

A B

C

D

top related