February 2017
Beginner
1056 pages
28h 57m
English
switch StatementDetermine on some course, more than a wild exposure to each chance that starts i' the way before thee.
—WILLIAM SHAKESPEARE, Coriolanus (1609)
When a multiway if-else statement has many possible outcomes, it can be hard to read. If the choice is based on the value of an integer or character expression, the switch statement can make your code easier to understand.
The switch statement begins with the keyword switch followed by a controlling expression in parentheses:
switch (Controlling_Expression)
{
. . .
}
The body of the statement is always enclosed in a pair of braces. Listing 3.5 shows a sample switch statement, whose ...
Read now
Unlock full access