You are on page 1of 2

Dr. A.

Q Khan School System


(Ibraheem Campus Islamabad)

_____________________________________________________________________________________

Class 10th Computer notes


Chap No:. 04 Conditional Control Structure
1) What is CONROL STATEMENT

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.

2. What is CONDITIONAL STATEMENT

Ans: A conditional statement is an instruction in a programming language that contains a condition.


When a conditional statement is executed, first the condition is evaluated and then based on the result
(true or false), a particular statement or a set of statements is executed.

3. How many conditional statements?

Ans: Conditional statements of C language are if, if-else, else-if and switch statements.

4. What is if statement? Why we used if statement?

An if statement is a programming conditional statement that, if proved true, performs a function or


displays information.

5. What is if-else statement? Why we used if –else statement?

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.

6. What is if-else –if statement? Why we used if –else –if statement?

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.

7. What is switch statement?

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

9. What is nested if 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.

10. Differentiate between if –else and switch statement in c programming


If else statement Switch statement
i. An if-then-else statement can test I. A switch statement tests expressions
expressions based on ranges of values or based only on a single integer,
conditions enumerated value, or String object.
ii. If-else conditional branches are great for II. switch statements are great for fixed
variable conditions that result into a data values.
Boolean III. A switch statement might prove to be
iii. ifs provided number of cases are good faster

11. Compare structure between conditional statements


If statement If- else statement If-else-if statement Switch statement

if (condition) if (condition) if(condition-1) switch (expression)


{ { { Block of statements } { case const-1:
Block of statements Block of statements else if(condition-2) statements;
} } { Block of statements } break;
Else if(condition-3) case const-2:
{ { Block of statements } statements;
Block of statements . break;
} . .
. .
else .
{ default:
Block of statements to { statements; }
be executed when none
of the conditions is
true.
}

You might also like