ECS 36B Lecture 3: Transitioning to C Part Two
ECS 36B verified notes
3/26View all
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";