What is the use of Nested Loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is the use of Nested Loop?

29th Mar 2019, 6:40 AM
Syeda Shamapty
Syeda Shamapty - avatar
6 Answers
+ 8
When we use a loop inside another loop it is called nesting of loop. This loop can be used to access the elements of a multidimensional array or you can use it to make patterns etc...
30th Mar 2019, 6:47 PM
Prabhat Kumar Singh
Prabhat Kumar Singh - avatar
+ 12
You can use it for a number of purposes. 1. To access elements of a multi dimensional array 2. To access string elements 3. To print patterns of characters 4. To check for the working of a particular inside loop body 5. It is also used with complex if else structures
29th Mar 2019, 8:30 AM
Sulagna Dutta
Sulagna Dutta - avatar
+ 6
Useful for printing patterns and in iterating over multidimensional arrays and data structures.
30th Mar 2019, 1:17 PM
Ayush Sinha
Ayush Sinha - avatar
+ 3
Like others have already said, it is used in the multidimensional array or vector, and it is also used for sorting algorithom. Bubble Sort would be a example of this.
30th Mar 2019, 3:16 AM
Dan
Dan - avatar
+ 2
Nesting loops is a great way to reduce the amount of code needed in a program. Unless you require a linear solution. I mostly use nested loops for data matrix generation. Which then reads the matrix and writes a linear file for use in a cnc drill.
31st Mar 2019, 3:09 AM
Michael Williams
Michael Williams - avatar
0
Loop insiade another loop
21st Apr 2019, 7:22 AM
SAHIL