Page 215 - CA_Blue( J )_Class10
P. 215
47 System.out.print("\n");
48 }
49 else
50 {
51 System.out.print(ch+"\n");
52 }
53 }
54 }
55 }
Let’s Revisit
® A loop inside another loop is called a nested loop.
® If a for loop is used within another for loop, then it is called a nested for loop.
® If a while loop is used within another while loop, then it is called a nested while loop.
® If a do-while loop is used within another do-while loop, then it is called a nested do-while loop.
® The break statement is used for exiting the loop.
® The continue statement is used for executing the next iteration of the loop without executing rest of the loop statements.
MIND DRILL
Solved Questions
A. Tick ( ) the correct answer.
1. What will happen if the test condition given in the outer loop evaluates to false?
a. The outer loop will execute once.
b. The inner loop will execute, but the outer loop will not run.
c. The outer loop will terminate, and the inner loop will not execute.
d. Both loops will continue executing as long as their conditions are true
2. If the break statement is executed within the outer loop, then the control of the program will exit from the ………………… loop.
a. Outer b. Inner
c. Entire program d. Current iteration
3. Consider the following code:
int i, j, sum=0;
for(i = 1; i <= 5; i++)
for(j = 1; j <=5; j++)
sum = sum + j;
213
Nested Loop 213

