Download presentation
Presentation is loading. Please wait.
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;
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.