OUTPUT (after running):
Enter any vowel: i
You entered i.
Enter any vowel: u
You entered u.
Enter any vowel: r
You have not entered any vowel.
The output is therefore the same in both cases. Switches allow executing a set of statements for
more than one case label. We have seen that whenever a switch statement finds a match, it executes
all of the subsequent lines in the switch unless it encounters a break statement.
Also note here that if
you don’t use a default case and the switch statement does not find a match, then nothing gets
executed within the switch statement and control is transferred to the next statement, if any,
following the control structure.
The goto Statement
A goto statement is an unconditional control statement. It directly takes the “control the program”
statement wherever you want. Usually we don’t recommend the use of a goto statement, as it is an
unstructured way of programming. It makes programs nonreadable, unreliable, and difficult to debug.
For example,
Do'stlaringiz bilan baham: |