Notes
Notes
_____________________________________________________________________________________
Ans: A control statement is an instruction which determines the sequence of execution of other
statements. In other words, it controls the flow of execution of program statements.
Ans: Conditional statements of C language are if, if-else, else-if and switch statements.
The if-else statement is used in situation where some code is to be executed if a condition is true and
some other code is to be executed if the condition is false.
The else-if is a type of conditional statement that combines more than two conditions. It allows the
programmer to make a decision based on several conditions.
The switch statement is similar to the else-if statement. It is used when multiple choices are given and
one choice is to be selected. When switch statement is executed, the expression is evaluated. Based on
the result of expression one of the cases in the switch statement is executed. The result of expression is
compared with the constant values given after the keyword case. If the result matches the constant
value after any case then the statements under that case are executed.
8. Write Advantage and Limitation of switch Statement.
The switch statement allows a variable to be compared against a list of constant values. When there is a
match to a case, the statements following that case will execute until a break statement is reached. This
makes the logic of program simple and easy to understand.
The switch statement has a limitation. It is not allowed to use relational operators in the expression of
switch statement
The selection structure that is within another selection structure is known as nested selection structure.
Sometimes, in computer programming, it is required to use a selection structure within another
selection structure.