Introduction to Nesting of Loops in C language.

“Dreams – is not what you see in sleep , it is the thing which doesn’t let you sleep”
Hello everyone!!! 🙂
In last few articles we have seen For loop, While loop and Do while loop in detail. Today we are going to see a short introduction of Nesting of loops.
Before moving to nesting of loops, let’s see some of the difference points between for loop, while loop and do while loop.

What is Nesting of loops???? •
Nesting of loops is a feature of C language which allows any number of loops can be defined inside another loop, i.e., there is no restriction for defining any number of loops.
The nesting level can be defined at n times. You can define any type of loop inside another loop.
for example, you can define ‘while’ loop inside a ‘for’ loop. looping of statements inside another loop.
Let’s see syntax of nesting of loops:-
Outer_loop
{
Inner_loop
{
// inner loop statements.
}
// outer loop statements.
}
•How exactly the nesting of loops works??
A nested loop has one loop inside of another.
These are typically used for working with two dimensions such as printing stars in rows and columns as shown below.
When a loop is nested inside another loop, the inner loop runs many times inside the outer loop. In each iteration of the outer loop, the inner loop will be re-started.
The inner loop must finish all of its iterations before the outer loop can continue to its next iteration.
We can do nesting of all the three loops i.e of for loop, while loop and do while loop.
We will see nesting of loops in detail with examples in upcoming article, soo be connected.
Soo let’s meet in the next article till then take care and goodbye 🙂 Have a great day ahead 🙂
You must be logged in to post a comment.