12th Computer Science for Session:2022-23
Chapter 2nd
Control Statements
Objective Type Multiple Choice Questions:
1. Which of the following statement is also called as conditional statement?
a. for b. break c. if d. while
2. switch-case is similar to ________________ statement
a. if else b. if else if c. break d. goto
3. Which statement can be used to terminate a case in the switch statement?
a. continue b. goto c. if d. break
4. Which of the following is an example of Post Test loop?
a. for b. while c. do while d. continue
5. Which of the following is not a jumping statement?
a. while b. continue c. goto d. break
Fill in the Blanks:
1. In ____________ loops, the control conditions are tested before the body of loop
2. In ____________ loops, the control conditions are tested after the body of loop
3. ______________ statement is used to skip some statements inside the loop
4. _______________ is a multi-way conditional control statement
5. The break statement can be used to terminate a case in the _________ statement.
Ans: 1. Pre-Test 2. Post-Test 3. continue 4. Switch case 5. switch
Very Short Answer Type Questions:
Q:1 Writing if statement with-in another if is called as?
Ans: Nested if statement
Q:2 Which statements in C programming are used for altering the normal flow of a program?
Ans: Control Statements
Q:3 Which statement is sometimes desirable to skip some statements inside the loop?
Ans: Jumping Statement - Continue
Q:4 Which statements provide a way to repeat commands?
Ans: Looping Statements
Short Answer Type Questions:
Q:1 Define Branching? Name its different control statements?
Ans: Those control statements which are used for decision making purpose or for making multi-way
selection in the program are called Branching Statements. These statements choose to follow one branch
or another during execution in the program. Branching statements are of the following two types:
Conditional Control Statements (if else)
Multiway Conditional Control Statement (switch case)
Q:2 What is looping? Name three different types of looping statements?
Ans: Those control statements which are used to repeat a set of statements in the program are called
looping statements. Looping statements are also called Iterative Statements. Following three looping
statements are used in the C programming:
for loop
while loop
do while loop
Prepared By: Vikas Kansal (CF, S.U.S. Govt. Sen. Sec. School (Girls), Sunam Udham Singh Wala) Page No: 5
(Please Visit http://cspunjab.nirmancampus.co.in for more computer science contents)
12th Class Computer Science (Session 2021-22)
Q:3 What is nested if statement? Write its syntax?
Ans: When one if statement is used within another if statement, it is known as nested if statement.
Syntax of nested if statement if given following:
if (test_condition_1)
{
if (test_condition_2)
{
statements;
}
}
Q:4 What is if-else statement? Write a program of if-else statement?
Ans: if else statement is a branching statement. It is used for decision making purpose in the C
programs. Following program shows the usage of if else statement:
#include<stdio.h>
void main() Output:
{
int marks=45; Pass
if(marks>=35)
printf(“Pass”);
else
printf(“Fail”);
}
Q:5 What is while statement? Write its syntax?
Ans: while statement is a looping statement. It is used for repeating set of statements in the program. It
is a type of pre-test loop in which test condition is tested before the execution of body of the loop.
Following is the syntax of the while statement:
while (test_condition)
{
statements;
}
Long Answer Type Questions:
Q:1 What are Control Statements? Explain their types.
Ans: When a program executes line by line in the given sequence, it is called Sequential Execution of
the program. We can control this execution flow in the program as per our requirements. Those
statements that control the flow of execution of statements in the program are called Control
Statements. These statements can be classified into following three categories:
Branching Statements (if else and switch case)
Looping Statements (for, while and do while)
Jumping Statements (goto, break and continue)
Prepared By: Vikas Kansal (CF, S.U.S. Govt. Sen. Sec. School (Girls), Sunam Udham Singh Wala) Page No: 6
(Please Visit http://cspunjab.nirmancampus.co.in for more computer science contents)
12th Class Computer Science (Session 2021-22)
Q:2 What is switch statement? Write a program of switch statement?
Ans: switch statement is a multiway conditional control statement. This statement is similar to the if
else if statement. It is a matter of preference which we use from these statements. switch statement can
be slightly more efficient and easier to read. In switch-case, statements get executed when corresponding
case constants are true only. Statements of defaults block gets executed only when all other cases are
false. Following program shows the usage of switch statement in the program:
Q:3 What is for loop? What are the two different categories of loops?
Ans: Looping statements are also called Iterative Statements. Sometimes we face situations that require
repeated exection of statements in the program. In such situtaions, loops help us to repeat statements
in the program. Loops can be categorized into following two types:
Pre-Test Loops: Pre-Test loops are also called Entry-Controlled loops. In these loops, test
condition is tested before the body of the loop. ‘for’ and ‘while’ loops are the examples of pre-
test loops.
Post-Test Loops: Post-Test loops are also called Exit-Controlled loops. In these loops, test
condition is tested after the body of the loop. ‘do while’ loop is an example of post-test loop.
Prepared By: Vikas Kansal (CF, S.U.S. Govt. Sen. Sec. School (Girls), Sunam Udham Singh Wala) Page No: 7
(Please Visit http://cspunjab.nirmancampus.co.in for more computer science contents)
12th Class Computer Science (Session 2021-22)
Q:4 What is jumping statement? Explain its types?
Ans: Jumping statements in the C progamming are used to change the normal execution flow of the
program. We can transfer the exection flow from one location to some other location in the program.
Following jumping statements are used in the C programming:
goto statement: For using these statements, we have to use labels in the program. This statement
transfers the execution control at the label specified after the goto statement.
break statement: This statement is used to terminate the exection of a loop or switch statement
and transfter the execution control immediately after the loop or switch statement.
continue statement: Sometimes it is benficial to skip statements in the loop. continue statement
is used in such situtations.
Q:5 What is do while loop? How it differs from while loop?
Ans: ‘do while’ loop is a post test loop. The ‘do while’ loop is the only loop which is known as the post-
test loop in C programming. In ‘do while’ loop, test-condition is tested after the exection of body of the
loop. In this loop, minimum number of executions for the body of the loop will be one. It is so because
whenever this loop is executed for the first time, its body gets executed without executing the test-
condition of the loop.
‘do while’ loop is different from the ‘while’ loop. ‘while’ loop is a pre-test loop in which test condition
is tested before the execution of body of loop. The minimum number of executions for the body of the
loop will be zero. It is so because whenever this loop is executed, its body can not be executed without
executing the test-condition even once.
Prepared By: Vikas Kansal (CF, S.U.S. Govt. Sen. Sec. School (Girls), Sunam Udham Singh Wala) Page No: 8
(Please Visit http://cspunjab.nirmancampus.co.in for more computer science contents)