ENG 1002 Lecture Notes - Lecture 8: Switch Statement, Matlab, Printf Format String

6 views7 pages

Document Summary

Topic 9: iteration, selection, static arrays, library functions. Each clause/block in an if-statement is surrounded by the curly brackets { }. C uses the keyword else to perform the code when the condition is not met. For example: if the variable value is greater than or equal to 5, if (value >= 5) , display high five, else { We can also chain if statements together as we saw in matlab. Matlab uses elseif, c uses else if. Switch statements in c are shorthand for nested if-statements. Switch statements only check for equality for single numeric or single character values. A break statement is required at the end of each case to prevent the program from executing the next case statement. The final case in each switch statement is default not otherwise. For looks in c are defined by 4 parts: a starting value, a looping condition, an incrementation step, code block.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions