English

What is a nested loop? - Computer Applications

Advertisements
Advertisements

Question

What is a nested loop?

Answer in Brief

Solution

'A nested loop is one that uses another loop within itself. In the example below, the outer loop is executed three times. The inner loop is executed twice per outer loop iteration. Therefore, the pattern printed will be: 

          MM
          MM
          MM

Example: 

for (int i = 1; i <= 3; i++)
{for (int j = 1; j <= 2; j++)
System.out.print("M");
System.out.printIn();
}
shaalaa.com
  Is there an error in this question or solution?
Chapter 1.1: Nested Loop - EXERCISES [Page 145]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.1 Nested Loop
EXERCISES | Q III. 1. | Page 145
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×