118 Programming and Data Structures
simple and easy way. Simple & ample examples have been explained on decision-making statements.
To change the flow of the program the programmer can use statements such as b r e a k , continue and
goto. The Reader is expected to execute all the programs given in this chapter so as to achieve the
expertise in handling decision-making statements in the programs. If more real life problems are
writen by the programmer then it becomes beneficial.
EXERCISES
A) Answer the following questions
1) Is it possible to use multiple else with if statement?
2) Is it possible to use multiple default statements in swi tch () statement?
3) Write the use of else and default statements in i f . .e ls e and switch () statements respectively.
4) Why go to statement is avoided?
5) Why break statement is essential in swi tch () statement? Which other functions or keywords
can be used in place of the break statement.
6) Is it possible to use e ls e statement in place of default or vice versa?
7) Can we put default statement anywhere in the swi tc h () case structure?
8) What are the limitations of swi tch () case statement?
B) Answer the following by selecting the appropriate option.
1) The switch statement is used to
a) Switch between functions in a program.
b) switch from one variable to another variable.
c) choose from multiple possibilities which may arise due to different values of a single
variable.
d) use switching variables.
2) The default statement is executed when
a) all the case statements are false
b) one of the case is true
c) one of the case is false
d) none of the above
3) Each case statement in swi tch () is seperated by
a) break b) continue
4) The keyword else can be used with
a) i f statement
c) do..w hile() statement d)
5) What will be the output of the following program?
# include <stdio.h>
# include <conio.h>
void main ()
{
char x='H ';
c lr s c r ();
switch(x)
{
case 'H': printf("%c"/H');
c) e x it() d) goto
b) switch () statement
none of the above