Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
The Keyword Default | Conditional Statements
Introduction to C++ | Mobile-Friendly
course content

Зміст курсу

Introduction to C++ | Mobile-Friendly

Introduction to C++ | Mobile-Friendly

1. Basics
2. Variables
3. Conditional Statements
4. Loops
5. Intro to Arrays

The Keyword Default

To specify the code to execute if there is no case match, you can use default keyword in switch statement. For example, the coffee machine has a list of types of coffee by its number (from 1 to 3). If you want to choose one, just type its number. But there is a huge amount of numbers that users can type by mistake. Here we can use the default keyword:

The default statement executes the code when the non of statements are true.

The default statement must be at the end of the switch.

question-icon

Fill the gaps:

The default keyword specifies some code to runand it.

Натисніть або перетягніть елементи та заповніть пропуски

Все було зрозуміло?

Секція 3. Розділ 8
We're sorry to hear that something went wrong. What happened?
some-alt