Learn C Programming

Lesson 3 of 7 · Decisions

Module 5 · Decisions

switch, case and Fall Through

Free with an accountReading

David wrote the menu for his café's order screen: 1 for tea, 2 for coffee, 3 for juice. A customer pressed 2.

Sign in to read

This lesson is free, with an account

An account costs nothing and opens every lesson in this track that is not marked Pro, on every device you read on.

What is inside switch, case and Fall Through

  1. switch: one value, many constants
  2. break, and what happens without it
  3. default, and where it goes
  4. Grouping cases, and switching on a char
  5. Fall through on purpose, with a comment
  6. What switch cannot test
  7. switch or an else if ladder?