MIME-Version: 1.0 Server: CERN/3.0 Date: Sunday, 24-Nov-96 22:48:21 GMT Content-Type: text/html Content-Length: 10203 Last-Modified: Wednesday, 16-Oct-96 13:58:46 GMT rdz9

CS100B

Lecture 9

CONCEPTS --- last lecture

Simple expressions and programs; call/assignment statements and their evaluation; examples

CONCEPTS --- this lecture

Compound statements and scoping rules; blocks and declarations; fun with else; iteration with while and break; fencepost errors

HANDOUT: Sample Prelim #1 questions

Prelim #1 notes

Compound statements

Scoping rules

Where have we seen compound statements?

Fun with else

Iteration

Example
void countdown(int count){ while (count > 0) {printf("%d…",count); count = count - 1;} printf("Blastoff!");}
void main(){ start = 10; countdown(start); printf("%d",start);}

Break statements

What about nested while statements?

Iteration and the stack model

Fencepost errors