CS136 Lecture Notes - Lecture 4: Semicolon, Mutation, Imperative Programming

28 views4 pages

Document Summary

Void functions: only generate a side effect, and not return a value, return has no expression and its optional, declare that function returns nothing . // effects: displays a message void say_hello (void) { printf ( hello!\n ); return; Expression statements: an expression followed by a semicolon (;, printf is not a void function. Returns an int corresponding to the number of characters printed printf ( hello!\n ); ==> value = 7. The following example is a single block (compound statement) that contains a sequence of five expressions statements with the values of 9, 10, 11, 12, A sequence of statements: expression statements. For generating side effects: the only other type of statements are control flow statements. Control flow statements: change the flow of the program and the order in which other statements are executed. The if (and else) statements execute statements conditionally. 1university of waterloo, 03-imperative-c, p 31, snapshotted by author.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents