Write about nested loop, with syntax and an example.
{JAVA}
Share
Write about nested loop, with syntax and an example.
{JAVA}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
I hope it helpful to you..
Verified answer
Answer:
Nested loop means a loop statement inside another loop statement. That is why nested loops are also known as “loop inside loop“.
Syntax for Nested for() loop:
for ( initialization; condition; increment ) {
for ( initialization; condition; increment ){
// statement of inside loop
}
// statement of outer loop
}
Example:
for(int i=1;i<=r; i++) // outer loop
{
for(int j=1;j<=r;j++) // inner loop
{
System.out.print("# ");
} // end of j loop
System.out.println();
} // end of i loop