previous | index | next

The break Statement

The break statement causes the switch statement to be exited.

Suppose movieRating was written like this:

void movieRatingWrong(int rating) {
  switch (rating) {
  case 4: cout << "Excellent";
  case 3: cout << "Good";
  case 2: cout << "Fair";
  case 1: cout << "Crappy";
  default: cout << "Invalid rating";
  }
}

What would be the result of calling "movieRatingWrong(4);"?


previous | index | next