Computer Science, asked by Anonymous, 1 year ago

What is nested loop? Give an example.

Answers

Answered by Anonymous
9

A nested loop is a loop within a loop, an inner loop within the body of an outer one. ... Then the second pass of the outer loop triggers the inner loop again. This repeats until the outer loop finishes. Of course, a break within either the inner or outer loop would interrupt this process.

If a loop exists inside the body of another loop, it's called nested loop. Here's an example of nested for loop. Here, a for loop is inside the body another for loop.

hope its help you

Answered by CopyThat
8

Answer :-

Nested loop :-

  • A loop within another loop is called a nested loop.

Example :-

public class Loop

{

static void Nested()

{

int x , y;

for(x=1;x<=3;x++)

{

for(y=1; y<=3 ; y++)

{

System.out.println(x+“ ”+y);

}

}

}

Output :-

1 1

1 2

1 3

2 1

2 2

2 3

3 1

3 2

3 3

}

Similar questions