{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# L06 - CME/Energy 211 Margot Gerritsen Shela Aboud Emmet...

This preview shows pages 1–9. Sign up to view the full content.

CME/Energy 211 Margot Gerritsen Shela Aboud Emmet Caulfield

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

View Full Document
Lecture Overview • Finish while and do-while loops • Enumeration Types: enum • Aggregate Type: struct • Union Type: union sizeof operator typedef • Aggregates type: arrays and strings
Example – Integration using for ) ( x f n a b h h i a f b f a f h dx x f b a n i = + + = 1 1 ) * ( 2 ) ( ) ( ) ( h Trapezoidal Rule x

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

View Full Document
Iteration Statements – while while ( expression ) statement; • If expression is evaluated as nonzero (true) the statement continues to be executed. • The cycle is terminated when expression evaluates to 0 (false). • An omitted expression is replaced by a nonzero constant – infinite loop init_expr ; while ( test_expr ) { statement; loop_expr ; } while vs. for loops for ( init _ expr ; test_expr ; loop_expr ) { statement; }

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

View Full Document
Iteration Statements – do-while do { statement; } while ( expression ); • The do - while loop executes the statement before checking if the expression is true, unlike the for and while loops which evaluate the expression before executing the statement . • Although braces are not required when only one statement is included, they should be used anyway to avoid confusion with the while loop.

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

View Full Document
return – used to return from a function; cannot be used if return type of function is void. goto – discouraged because it makes the code unreadable (condemnation cannot be too strong here!) break – used to terminate the a switch or iteration statement; may only be used in the body. continue
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 21

L06 - CME/Energy 211 Margot Gerritsen Shela Aboud Emmet...

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

View Full Document
Ask a homework question - tutors are online