in nested loop, which loop is terminated first
(a) outer loop
(b) inner loop
(c) both loop terminated same time
(d) none of the above
Answers
Question:-
- which loop is terminated first
A)outer loop
B)inner loop
C)both loop terminated at same tiime
D)none of the above
Answer:
OPTION (B) :-Inner loop
Explanation:
The concept of nested loop can be well understood by the small example:-
Suppose there is a box, inside this box there is one more box containing some foods.
So, in order to take out that food
first you open the outer box,
then you open then inner box,
then you take out the food
Then close the inner box
then you close the outer box
So in this example you saw... first you closed the inner box then you closed the outer box....
Nested Loop also gave same concept
Outer loop starts first
Then inner loop
Then control executes the statements
Then inner loop closes
Finally, Outer loop also closes
Hence First Inner loop closes then outer loop closes