Computer Science, asked by ridhamdhoalria, 1 year ago

can anyone explain me nested for loop

Answers

Answered by priyanka9432
0
yeah off course .....here u got it??

A nested loop is a loop within a loop, an inner loop within the body of an outer one. ... Of course, a break within either the inner or outer loop would interrupt this process.

The number of digits in the web page counter or the odometer determine the number of nested loops needed to imitate the process.
When working with nested loops, the outer loop changes only after the inner loop is completely finished (or is interrupted.).

example: class Ascending { public static void main(String args[]) { int temp; int a[] = {20, 10, 80, 70}; for (int i = 0; i < 4; i++) { System.out.println(a[i]); } for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { if (a[i] > a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } System.out.println("\n after:"); for (int i = 0; i < 4; i++) { System.out.println(a[i]); } } }

Output:

20
10
80
70

ridhamdhoalria: i am really serious
priyanka9432: mark it as the brainliest answer
Answered by twinkle1125
2
Hey mate...

A loop inside another loop is known as nested loop.

Hope it helped u...☺️☺️

ridhamdhoalria: explain its syntax and how to use itn
priyanka9432: i have mentioned
priyanka9432: pls have a look
Similar questions