1st PUC Computer Science Question Bank Chapter 10 Control Statements

You can Download Chapter 10 Control Statements Questions and Answers, Notes, 1st PUC Computer Science Question Bank with Answers Karnataka State Board Solutions help you to revise complete Syllabus and score more marks in your examinations.

Karnataka 1st PUC Computer Science Question Bank Chapter 10 Control Statements

1st PUC Computer Science Control Statements One Mark Questions and Answers

Question 1.
What is a statement?
Answer:
Statements are the instructions given to the computer to perform specific of actions. Action may be in the form of data movement, decision making, etc.

Question 2.
What are control statements?
Answer:
Control statements are elements in the program that can control and alter the sequence of flow of constructions in any program execution.

Question 3.
Write the classification of control statements.
Answer:
The control statements are classified as

a
  1. Selection statements
  2. Iterative statements and
  3. Jump statements.

Question 4.
What is meant by a compound statement?
Answer:
A compound statement is a grouping of statements enclosed within a pair of braces ({ }), in which each individual statement ends with a semi-colon.

Question 5.
What are selection statements?
Answer:
The selection statements are used to execute certain block of statements after evaluating the condition.

Question 6.
What is a block?
Answer:
A group of statements separated by semicolons and grouped together and enclosed within brackets marked with { } is called a block.

KSEEB Solutions

Question 7.
What is the purpose of ‘if’ statement?
Answer:
The ‘if’ statement is used to decide on whether a statement or a block should be executed or not.

Question 8.
What is the other name of ‘if’ statement?
Answer:
The other name of ‘if’ statement is one-way branching statement.

Question 9.
Give the possible output of condition evaluation.
Answer:
The possible output of condition evaluation is either TRUE or FALSE.

Question 10.
What is the numerical equivalent of TRUE or FALSE?
Answer:
The numerical equivalent of TRUE is 1 and FALSE is 0.

Question 11.
What is the other name of ‘if-else’ statement?
Answer:
The other name of ‘if-else’ statement is two-way branching.

Question 12.
When is ‘if-else’ statement used?
Answer:
‘If else’ statement is a conditional branching statement used to execute a set of codes when the condition is true, otherwise executes a different set of the codes in the “else” part.

Question 13.
What is an ‘if-else-if’ statement?
Answer:
The ‘if-else if’ statement is an extension of the “if-else” conditional branching statement. When the expression in the “if’ condition is “false” another “if-else” construct is used to execute a set statement based on an expression.

Question 14.
What is ‘nested if’?
Answer:
An if statement nestling inside another ‘if’ statement is termed as ‘a nested if’ statement.

Question 15.
Give the name of multi-branch selection statement.
Answer:
The multi-branch selection statement is called as ‘switch-case’ statement.

KSEEB Solutions

Question 16.
Give the purpose of the switch statement.
Answer:
The ‘switch’ statement is used in C++ for testing whether a variable is equal to any one of a set of values.

Question 17.
Define the term looping.
Answer:
Looping means execution of a statement or block of statements repeatedly until the condition is true.

Question 18.
Why is ‘while’ loop called a pre-tested looping statement?
Answer:
The ‘while’ loop evaluates the condition in the beginning itself, to select a suitable statement for execution repeatedly. Therefore it is called a pre-tested looping statement.

Question 19.
What is post-tested looping statement?
Answer:
The loop evaluates the condition at the end of the looping structure and selects a statement for execution repeatedly. Therefore it is called a post-tested looping statement.

Question 20.
Name the post-tested looping statement.
Answer:
The ‘do-while’ statement is a post-tested looping statement.

Question 21.
Which structure is called a fixed-execution looping statement?
Answer:
The ‘for’ looping statement is called a fixed-execution looping statement.

Question 22.
When is ‘for’ used?
Answer:
If the programmer knows the exact number of repetitions to be carried out among the set of statements then ‘for’ conditional statement is used in a program.

Question 23.
What is nesting of loop?
Answer:
If the loop appears inside the body of another loop it is called a nested loop.

Question 24.
What is the purpose of ‘break’ statement?
Answer:
The ‘break’ statement can be used to terminate a repeated structure (loops) such as ‘while’, do-while ‘and’ ‘for’ and multi-branching statements like ‘switch’.

Question 25.
What is the use of ‘goto’ statement?
Answer:
The ‘goto’ statement transfers/jump control from one part of the program to some other part.

Question 26.
What is the function of ‘continue’ statement?
Answer:
The ‘continue’ statement is used in loops and causes a program to skip the rest of the body of the loop.

KSEEB Solutions

Question 27.
Why is the ‘exit() library’ function used?
Answer:
The execution of a program can be stopped at any point with ‘exit ( )’ and a status code can be informed to the calling program.

1st PUC Computer Science Control Statements Two/Three Marks Questions and Answers

Question 1.
What are control statements? How are they classified?
Answer:
Control statements are elements in the program that control the flow of program execution. Control statements are classified as,

  1. Selection statements
  2. Iterative statements
  3. Jump statements

Question 2.
What are selection statements? Give the different types of selection statements.
Answer:
Selection statements are used to execute certain block of statements by evaluating the conditions.
The different selection statements are

  1. ‘if’ statement
  2. ‘if-else’ statement
  3. ‘if-else-if’ (nested) statement
  4. ‘switch’ statement

Question 3.
Give the syntax of ‘if’ statement.
Answer:
The syntax of if statement is
if (condition)
{
statement 1;
statement 2;
statement n;
}

KSEEB Solutions

Question 4.
Write the flowchart representation of ‘if’ statement.
Answer:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 1

Question 5.
Write the syntax of ‘if-else’ statement.
Answer:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 2

Question 6.
Write the flowchart representation of ‘if-else’ statement.
Answer:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 3

Question 7.
Write the syntax of if-else-if statement.
Answer:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 4

Question 8.
Write the flowchart representation of ‘if-else-if’ conditional structure.
Answer:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 5

Question 9.
Write the syntax of‘switch-case’ statement.
Answer:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 6

Question 10.
Write the comparison between ‘if-else’ and ‘switch-case’ statement.
Answer:
The ‘if-else’ statements permit two-way branching, whereas ‘switch’ statement permits multiple branching.

Question 11.
Write the syntax of ‘while’ loop.
Answer:
Syntax of ‘while’ loop:
while(condition)
{
statement(s);
}

KSEEB Solutions

Question 12.
Write the syntax of ‘do-while’ loop.
Answer:
Syntax of ‘do-while’ loop
do
{
statements;
} while (condition);

Question 13.
Write the flowchart of representation of while loop.
Answer:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 7

Question 14.
Write the flowchart representation of ‘do-while’ loop.
Answer:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 8

Question 15.
Give the difference between ‘break’ and ‘exit()’ statements.
Answer:
The ‘break’ statement can be used to terminate a repeated structure (loops) such as ‘while’, do-while and for and multi-branching statements like ‘switch’.
The execution of a program can be stopped at any point with ‘exit ( )’.

Question 16.
Give the difference between ‘goto’ statement and ‘continue’ statement.
Answer:
The ‘goto’ statement transfers/jump control from one part of the program some other part. The ‘continue’ statement is used in loops and causes a program to skip the rest of the body of the loop.

1st PUC Computer Science Control Statements Five Marks Questions and Answers

Question 1.
Explain the working of ‘ if’ statement and ‘if-else’ statement with examples.
Answer:
Example for ‘if’ statement:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 9
Result:
B is greater than A
In the above example the condition in the if statement returns a true value and so the text “B is greater than A” is displayed.
Example for ‘if else’ statement:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 10
Result:
B is greater than A.
In the above example, the “if’ condition is false so the code in the “else” part is executed.

KSEEB Solutions

Question 2.
Explain the working of if-else if statement with a suitable example.
Answer:
The ‘if-else if’ statement is an extension of the “if-else” conditional branching statement. When the expression in the “if’ condition is “false” another “if-else” construct is used to execute a set of statements based on the expression.
Syntax:
if(expression)
{ statements }
else if(expression)
{ statements }
else if(expression)
{ statements }
Example: for ‘if else if’ statement
1st PUC Computer Science Question Bank Chapter 10 Control Statements 11
1st PUC Computer Science Question Bank Chapter 10 Control Statements 11a
Result:
Enter your Percentage::60
First Class
In the above example, the ‘if else if’ statement is used to check multiple conditions based on the percentage of marks got, as input. The user entered percentage as 60, then first condition evaluated and returned with false. This resulted in checking for second if condition and resulted in true which give the print “first class”.

Question 3.
Write a short note on ‘switch-case’ statement.
Answer:
A ‘switch’ statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.
Syntax:
The syntax for a switch statement:
switch(expression)
{
case constant-expression : statement(s);
break; //optional
case constant-expression : statement(s);
break; //optional
default                              : statement(s);                 //Optional
}
The following rules apply to a switch statement:

  1. The expression used in a ‘switch’ statement must have an integer or enumerated type.
  2. We can have any number of case statements within a ‘switch’. Each case is followed by the value to be compared to, and a colon.
  3. The constant-expression for a case must be the same data type as the variable in the ‘switch’,
    and it must be a constant or a literal.
  4. When the variable being switched on is equal to a case, the statements following that case will execute until a ‘break’ statement is reached.
  5. When a ‘break’ statement is reached, the ‘switch’ terminates, and the flow of control jumps to the next line following the ‘ switch ’ statement.
  6. Not every case needs to contain a break. If no break appears, the flow of control will fall through to subsequent cases until a ‘break’ is reached.
  7. If no conditions match, then the code under the default statement is executed.
  8. The default case is used for performing a task when none of the cases is ‘true’.
  9. No break is needed in the default case.

KSEEB Solutions

Question 4.
Explain ‘switch-case’ statement with a suitable program example.
Answer:
‘ Switch’ statement compares the value of an expression against a list of integers or character constants. The list of constants are listed using the “case” statement along with a “break” statement to end the execution.
Example:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 12
1st PUC Computer Science Question Bank Chapter 10 Control Statements 13
Result:
Enter the day of the week between 1-7::7
Sunday
In the above Control Structure example, the “switch” statement is used to find the day of the week from the integer input got from the user. The value present in the day is compared for equality with constants written in the word case. Since no equality is achieved in the above example (from 1 to 6), when 7 is entered default is selected and gives “Sunday” as a result.

Question 5.
Explain ‘while’ loop structure with an example.
Answer:
A ‘while’ loop statement repeatedly executes a statement or sequence of statements written in the flower brackets as long as a given condition returns the value ‘true’.
Syntax:
The syntax of a ‘while’ loop in C++ is:
while(condition)
{
statement (s) ;
}
Here the condition may be any expression, and for true is any non zero value. The loop iterates while the condition is true. When the condition becomes false, program control passes to the line immediately following the loop. During the first attempt, when the condition is tested and the result is false, the loop body will be skipped and the first statement after the ‘while’ loop will be executed.
Example:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 14
When the above code is executed, it produces the following result:
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14

KSEEB Solutions

Question 6.
Explain the working of ‘for’ loop structure.
Answer:
A ‘for’ loop is a repetition control structure, that allows you to efficiently write a loop that needs to execute a specific number of times.
Syntax:
The syntax of a ‘for’ loop in C++ is:
for (initialization; condition; increment/decrement)
{
statement(s);
}
The working of a ‘for’ loop:

  1. The initialization step is executed first, and only once in the beginning. It is used to declare and initialize loop control variables.
  2. Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and the flow of control jumps to the next statement just after the ‘for’ loop.
  3. After the body of the ‘for’ loop executes, the flow of control jumps back up to the increment/ decrement statement and update any ‘loop’ control variables.
  4. Then the condition is evaluated again. If it is true, the ‘ loop’ executes and the process repeats itself (body of ‘loop’, then increment step, and then again condition). After the condition becomes false, the ‘for’ loop terminates.

Example:
1st PUC Computer Science Question Bank Chapter 10 Control Statements 15
When the above code is compiled and executed, it produces following result:
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15

a