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

CS100B

Lecture 10

CONCEPTS --- last lecture

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

CONCEPTS --- this lecture

Additional C statements: for, switch; type coercion and its perils

HANDOUT: Prelim #1 answers

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