ECS 30 Lecture Notes - Lecture 9: Semicolon, Switch Statement, Control Flow

24 views4 pages

Document Summary

Else: provides a way to execute the code if the condition is false. Statements should be surrounded by braces {: if blocks are composed of only onestatement, braces can be omitted. Not recommended - can lead to errors: nested if statements. Monday, 16 april 2018: cascading if statements. Conditions are executed until one is satis ed: order matters: else if conditions will be executed only if the the. Rst if condition isn"t, and so on: on the other hand, if you only write if statements (instead of else-if) all conditions will be tested, unlimited number of else ifs, final else not mandatory. Remember: true returns 0: the switch statement. Expression can only be int or char. When the variable being switched on is equal to a case, the statements following that case will execute until a break statement is reached. Not every case needs to contain a break.

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