ECS 36B Lecture 3: Transitioning to C Part Two

80 views2 pages
Verified Note

Document Summary

Ecs 36b - lecture 3 - transitioning to c part two. #define red 0 replaces all occurrences of red in the program with 0. #define yellow 1 define ___ has no type, solely replaces the holder with its value. #define green 2 just another example switch( variable you want to check the value for ){ case yellow: // equivalent to if variable == value of yellow . //can only check one variable with switch break; //without the break, the switch falls through to the next case and so on case red: break; case green: break; default: // everything that"s not red green yellow will be handled by default. **value of an expression in switch cannot be a double** Example showing when the falling-through behavior of breaks is useful: switch( lettergrade ){ case a": case b": case c": // it will continue to drop through these cases return p";

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