answersLogoWhite

0


Best Answer

If one loop ends before the next begins then they are not nested at all -- they are completely independent. To be nested, one loop must contain the other loop in its entirety. That is, the inner, nested loop must start and end within the outer, containing loop.

Nested loop example (in C++):

for( int x = 0; x < 10; ++x ) // outer loop

{

for( int y = 0; y < 10; ++y ) // inner loop (nested loop)

{

printf( "%d x %d = %d\r\n", x, y, x*y );

} // end of inner loop

} // end of outer loop

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

In any programming language, the prime function of a loop is to carry on a desired function till the desired result is achieved. nested loop is a loop within a loop, an inner loop within the body of an outer one. The first clearance of the outer loop initiates the inner loop, which executes till the aim is achieved. Then the second clearance of the outer loop triggers the inner loop again. This repetition goes on until the outer loop finishes. A break within either the inner or outer loop would interrupt this process.

- JP Morgan

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: When loops are nested does one loop have to end before the other begins?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Why you use inner loop and outer loop?

Sometimes you have to use nested loops, in this case one of them is the outer, the other is the inner.


What is nesting in C programming?

Nesting can be a very handy tool in C++, but should be avoided if possible.C++ gives us If statements, For loops and many other things. These can be nested. For example:A nested If statement://outer if statementIf( this is true ){//nested if statementif( this is also true ){//do something}else{//do something else}}


Difference between ordered and unordered list?

unordered list: delineates a list, where the items are generally of equal importance and do not need to go in any particular order. Each item begins with a tag. Unordered lists may be nested inside unordered lists or inside any other types of lists (one list inside of another list inside of another list). A line space automatically is inserted before and after an unordered list (that is, an entire line is skipped between an unordered list and any text before and after it), except for (on most browsers) a list nested within another list.ordered list: delineates a list, where the items are in sequential, numerical order. Each item begins with a tag. Ordered lists may be nested inside ordered lists or inside any other types of lists (one list inside of another list inside of another list). A line space automatically is inserted before and after an ordered list (that is, an entire line is skipped between an ordered list and any text before and after it), except for (on most browsers) a list nested within another list.


What are tags between other tags called?

A tag located between other tags is called a nested tag.


What is nested tables?

In computing, nested refers to something inside another thing. Nested tables is having tables inside other tables. There are situations where this is useful. For example, normally you cannot have two tables beside each other in HTML. One way of doing that is to create one large table with a single row and two cells. Into each of the two cells you would put one table. The two tables will be sitting beside each other and they are nested insided the outer table. You could hide all borders on the outer table, further emphaisising the way the two tables are sitting beside each other. In furniture, it is a collection or set of tables that stack together.

Related questions

Why you use inner loop and outer loop?

Sometimes you have to use nested loops, in this case one of them is the outer, the other is the inner.


What is nesting in C programming?

Nesting can be a very handy tool in C++, but should be avoided if possible.C++ gives us If statements, For loops and many other things. These can be nested. For example:A nested If statement://outer if statementIf( this is true ){//nested if statementif( this is also true ){//do something}else{//do something else}}


When cooking what does nested mean?

One inside the other.


Difference between ordered and unordered list?

unordered list: delineates a list, where the items are generally of equal importance and do not need to go in any particular order. Each item begins with a tag. Unordered lists may be nested inside unordered lists or inside any other types of lists (one list inside of another list inside of another list). A line space automatically is inserted before and after an unordered list (that is, an entire line is skipped between an unordered list and any text before and after it), except for (on most browsers) a list nested within another list.ordered list: delineates a list, where the items are in sequential, numerical order. Each item begins with a tag. Ordered lists may be nested inside ordered lists or inside any other types of lists (one list inside of another list inside of another list). A line space automatically is inserted before and after an ordered list (that is, an entire line is skipped between an ordered list and any text before and after it), except for (on most browsers) a list nested within another list.


What are tags between other tags called?

A tag located between other tags is called a nested tag.


What are grouping symbols and what role do they play in the order of operations on mathematics?

Grouping symbols are parentheses such as {}, (), []. They need to be evaluated before other operations. If there are a number of nested parentheses, they must be evaluated starting with the innermost.


What are many loops of wire placed one on top of the other?

Coil :)


What is a nested triangle in math?

It is a triangle inside another shape, usually such that its vertices are on the boundaries of the other shape.


What does the term nesting mean?

"Nesting" can mean a couple of things:the habit of a bird or animal to build a home which is called a nestto fit a smaller object into a larger one.In mathematical or computer terms: It means to place the same function within a like function. For instance:for (int x = 0; x < 5; x++){for (int y = 0; y < 10; y++){for (int z = 0; z < 15; z++){cout


What is looping in programming languages?

In programming, a "loop" is a piece of code that is allowed to execute repeatedly until a condition is met. Under C, there are "for" and "while" loops. Other languages have "foreach" and "repeat..until" loops. A "for" loop optionally sets a variable at a certain value, and then executes a block of code while that (and perhaps other variables) meet(s) certain conditions. "While" loops are simpler types of loops since they only loop while a condition is met - variables are set before the "while" statement. See the related links below for more information on looping in C.


Does froot loops have iron?

well i know this guy and hes pretty fruity his name i jacib and his other friend is lirio so yes fruit loops are fruity!!!!!!!!!!!!!!!!!!!


What two paired cell structures are copied before mitosis begins?

Before mitosis begins, the chromosomes and other materials are copied. The pair of centrioles which are also copied. Each chromosome now consist of two chromatids.