0% found this document useful (0 votes)
2 views5 pages

? CHAPTER 11 Nested Loop

The document discusses nested loops in programming, explaining that a nested loop is one loop inside another and detailing how the inner loop executes for each iteration of the outer loop. It includes multiple-choice questions and short answer questions to reinforce understanding, as well as output-only questions demonstrating various nested loop patterns. The for loop is highlighted as the most suitable for nested loops, particularly in pattern generation.

Uploaded by

Arunangshu Das
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

? CHAPTER 11 Nested Loop

The document discusses nested loops in programming, explaining that a nested loop is one loop inside another and detailing how the inner loop executes for each iteration of the outer loop. It includes multiple-choice questions and short answer questions to reinforce understanding, as well as output-only questions demonstrating various nested loop patterns. The for loop is highlighted as the most suitable for nested loops, particularly in pattern generation.

Uploaded by

Arunangshu Das
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

🔁 CHAPTER 11: NESTED LOOPS

🔹 SECTION A – MCQs

1. A nested loop means

a) one loop inside another loop

b) many loops in sequence

c) loop inside if

d) infinite loop

✅ Answer: (a)

2. How many times will the inner loop execute in nested loops?

a) Once

b) Depends on outer loop

c) For each iteration of outer loop

d) Never

✅ Answer: (c)

3. Which loop is generally used for pattern programs?

a) if

b) while

c) nested for loop

d) switch

✅ Answer: (c)

4. In a nested loop, which loop controls number of rows?

a) Inner loop

b) Outer loop

c) Both

d) None

✅ Answer: (b)

5. Which loop controls number of columns?

a) Inner loop
b) Outer loop

c) Both

d) None

✅ Answer: (a)

🔹 SECTION B – Short Answer Questions

Q1. What is a nested loop?

Answer:

A nested loop is a loop inside another loop. The inner loop executes completely for each iteration of
the outer loop.

Q2. Why are nested loops used?

Answer:

Nested loops are used to print patterns, tables, and matrix-like outputs.

Q3. How many times does inner loop execute if outer loop runs 5 times?

Answer:

The inner loop executes completely for each iteration of the outer loop.

Q4. Which loop is best suited for nested loops?

Answer:

The for loop is best suited for nested loops.

🔹 SECTION A – MCQs

1. A nested loop is

a) loop inside switch

b) loop inside another loop

c) infinite loop

d) loop inside if

2. The loop that decides the number of rows is

a) inner loop

b) if loop

c) outer loop d) do-while loop


3. In nested loops, the inner loop executes

a) once only

b) infinite times

c) depends on outer loop

d) for each iteration of outer loop

4. Which loop is most commonly used for nested loops?

a) while

b) do-while

c) if

d) for

5. In pattern programs, [Link]() is usually written

a) outside both loops

b) after both loops

c) inside inner loop

d) inside outer loop

🔹 SECTION B – OUTPUT-ONLY QUESTIONS

Q1.

for(int i = 1; i <= 3; i++)

for(int j = 1; j <= 3; j++)

[Link]("*");

[Link]();

Q2.

for(int i = 1; i <= 4; i++)

for(int j = 1; j <= i; j++)

[Link](i);

[Link]();
}

Q3.

for(int i = 1; i <= 3; i++)

for(int j = 1; j <= i; j++)

[Link](j);

[Link]();

Q4.

for(int i = 3; i >= 1; i--)

for(int j = 1; j <= i; j++)

[Link]("*");

[Link]();

Q5.

for(int i = 1; i <= 3; i++)

for(int j = 3; j >= 1; j--)

[Link](j);

[Link]();

Q6.

for(int i = 1; i <= 3; i++)

for(int j = 1; j <= 3; j++)

if(i == j)

[Link]("1");
else

[Link]("0");

[Link]();

Q7.

for(int i = 1; i <= 4; i++)

for(int j = 1; j <= 4; j++)

[Link](i + j);

[Link]();

Q8.

for(int i = 1; i <= 3; i++)

for(int j = 1; j <= 3; j++)

if(j > i)

break;

[Link](j);

[Link]();

You might also like