lecture04 - Introduction to Low-Level Programming Concepts...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Low-Level Programming Concepts CMSC 212 ecture 4 1 CMSC 212 Lecture 4 September 10, 2009 Last time ● Chapter 3, Data – const – scope, storage class, linkage, and using the specifiers extern , static , auto , and register specifiers to modify them ● Chapter 4, Statements 2 CMSC 212 – expression statements and assignments – if statements – loops in C Reading ● Read Chapter 10 in Reek (Pointers on C) next 3 CMSC 212 Chapter 4, Statements, con't. 4 CMSC 212 Some loop examples (all variables are int ) while (x < y) { … } while (x < y && !error) { while (1) { … } do { 5 CMSC 212 … } while (!done) { while (x < y) { … } } … } while (x < y); Examples of for loops for (i= 0; i < 10; i++) a[i]= 0; for ( ; ; ) { 6 CMSC 212 … } for (i= 0, b= 21; i < 10; i++) { a[i]= b + i; } The switch statement ● Execution jumps to the case (if any) with constant-expression that has value equal to the expression 's ● If a break is executed, switch ( expression ) { case constant-expression 1 : statements 1 ; break; case constant-expression 2 : statements 2 ; reak; 7 CMSC 212 execution will jump to the next statement after the end of the entire switch ● A default case is optional, but if present matches when the value of expression is not the same as any of the constant-expression s break; … default: statements n ; break; } Example switch statement switch (choice) { case 'A': add_entry(); break; case 'D': case 'R': delete_entry(); reak; 8 CMSC 212 break; case 'P': print_entry(); case 'E': edit_entry();...
View Full Document

This note was uploaded on 11/23/2009 for the course CMSC 212 taught by Professor Staff during the Spring '08 term at Maryland.

Page1 / 6

lecture04 - Introduction to Low-Level Programming Concepts...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online