Flow of Control: book back answers
9 solved questions from the end of this chapter, Class 11 Computer Science, Tamil Nadu State Board. Each answer is checked against the textbook, and you can open the page that proves it.
← Notes and quiz for Flow of ControlSECTION – A Choose the correct answer
What is the alternate name of null statement?
- (A) No statement
- (B) Empty statement
- (C) Void statement
- (D) Zero statement
Try it, then show the answerAnswer
(B) Empty statement
The chapter refers to a null statement as a null or empty statement.
From the book: “The "null or empty statement" is a statement containing only a semicolon.”
In C++, the group of statements should be enclosed within:
- (A) { }
- (B) [ ]
- (C) ( )
- (D) < >
Try it, then show the answerAnswer
(A) { }
A compound statement is a group of statements enclosed by a pair of braces.
From the book: “C++ allows a group of statements enclosed by pair of braces {}.”
The set of statements that are executed again and again in iteration is called as:
- (A) condition
- (B) loop
- (C) statement
- (D) body of loop
Try it, then show the answerAnswer
(D) body of loop
The chapter calls the set of statements executed repeatedly the body of the loop.
From the book: “The set of statements that are executed again and again is called the body of the loop.”
The multi way branch statement:
- (A) if
- (B) if … else
- (C) switch
- (D) for
Try it, then show the answerAnswer
(C) switch
The switch statement is described as a multi-way branch statement.
From the book: “The switch statement is a multi-way branch statement.”
SECTION-B
What is a null statement and compound statement?
Try it, then show the answerAnswer
A null statement contains only a semicolon. A compound statement, or block, is a group of statements enclosed by a pair of braces {} and treated as a single unit.
The null statement is the empty statement form; the compound statement groups statements into a block.
From the book: “The "null or empty statement" is a statement containing only a semicolon.”
What is selection statement? write it's types?
Try it, then show the answerAnswer
A selection statement executes statements depending on a condition. The selection statements described in the chapter are if, if-else, nested if, if-else-if ladder, the conditional operator (?:), and switch.
A true condition selects a true block and otherwise a false block; switch selects a branch based on an expression's value.
From the book: “The selection statement means the statement (s) executed depend upon a condition.”
Compare an if and a ? : operator.
Try it, then show the answerAnswer
The ?: conditional operator is an alternative to the if-else statement. It evaluates a condition; if it is true, expression 2 is selected, otherwise expression 3 is selected. The if statement executes its true-block when its condition is true and otherwise skips that block.
Both use a condition to determine which code or expression is selected, but ?: uses three expressions and provides an alternative to if-else.
From the book: “The conditional operator (or Ternary operator) is an alternative for ‘if else statement’.”
Write the syntax and purpose of switch statement.
Try it, then show the answerAnswer
Syntax: switch(expression) { case constant 1: statement(s); break; case constant 2: statement(s); break; ... default: statement(s); } Purpose: It selects and executes a branch of code based on the value of the expression; otherwise, the default statements are executed if provided.
The expression is matched against case constants, and the matching case's statements execute.
From the book: “The switch statement is a multi-way branch statement.”
Explain in detail
Explain control statement with suitable example.
Try it, then show the answerAnswer
Control statements alter the sequence of flow of instructions in a program. They allow statements to be executed sequentially, selectively or iteratively.
- Purpose: Unlike sequential statements, control statements change the flow of execution, such as through branching, iteration, jumping and function calls.
- Sequential flow: Sequential statements execute one after another, only once, from top to bottom. They do not alter the flow of execution and end with a semicolon.
- Selection: A selection statement chooses which statement or block to execute based on a condition. If the condition is true, the true block executes; otherwise, the false block executes.
- Iteration: An iteration statement repeatedly executes a set of statements while the condition is true. Repetition stops when the condition becomes false.
- Conditional expressions: Selection and iteration statements depend on a conditional expression, which evaluates to true or false. In C++, any non-zero value is treated as true and zero as false.
- Example: if-else: In the chapter’s even-or-odd example, the remainder is stored in rem. If rem is zero, the number is identified as even; otherwise, it is identified as odd.
Example: The chapter demonstrates an if-else statement to check whether a number is even or odd: rem = num % 2; if (rem==0) the number is even, else it is odd.
Thus, control statements direct a program’s flow through sequence, selection and iteration.
From the book: “Control statements are statements that alter the sequence of flow of instructions.”