Page 262 - CA_Blue( J )_Class9
P. 262
Let’s Revisit
A nested loop is a loop inside another loop, where the inner loop executes completely for each iteration of the
outer loop.
There are 3 types of nested loops, nested for loop, nested while loop and nested do-while loop
The break statement is used to exit the innermost loop in a nested loop, transferring control to the next
statement after that loop.
The continue statement is used to skip the current iteration of the innermost loop in a nested loop and proceed to
the next iteration of that loop.
MIND DRILL
Solved Questions
A. Tick ( ) the correct answer.
1. When one loop is used within another loop, it is said to be a ………………… .
a. outer loop b. inner loop
c. nested loop d. composite loop
2. When a “break” statement is executed within the outer loop, then the ………………… loop will stop.
a. outer b. inner
c. both a and b d. composite loop
3. ………………… statement is used to exit the current loop.
a. break b. while
c. for d. continue
4. The use of a loop ………………… the program code.
a. elongates b. strengthens
c. reduces d. complicates
5. In a nested loop structure, which loop completes all its iterations for each iteration of the outer loop?
a. Inner loop
b. Outer loop
c. Both loops run independently
d. The outer loop completes all iterations before the inner loop starts
Answers
1. c 2. a 3. a 4. c 5. a
B. Fill in the blanks.
1. “break” and “continue” are both ………………… statements.
2. The total number of iterations in a nested loop is calculated by multiplying the iterations of the ………………… loop by
the iterations of the inner loop.
260 Touchpad Computer Applications-IX

