Presentation is loading. Please wait.

Presentation is loading. Please wait.

G6DICP - Lecture 5 Control Structures.

Similar presentations


Presentation on theme: "G6DICP - Lecture 5 Control Structures."— Presentation transcript:

1 G6DICP - Lecture 5 Control Structures

2 Loops A block of code is repeated
A pre-defined number of times Until a certain (boolean) condition is met Determinate vs indeterminate The contents of variables often change in each cycle. Beware of perpetual loops!

3 For Loops Probably the most common type of loop. for ( starting condition; continuing condition; change each cycle ) for ( a=1; a<=10; a++ ) { ... }

4 While Loops while (continuing condition) while (a<=10) { ... }

5 Do.. while Loops do { } while (continuing condition) do { } while (a<=10)

6 Switch switch (answer) { case ‘y’ : { ... } case ‘n’ : { ... }
default : { ... } } case ‘y’ : { ... }; break; case ‘n’ : { ... }; break; default : { ... }; break;


Download ppt "G6DICP - Lecture 5 Control Structures."

Similar presentations


Ads by Google