answersLogoWhite

0

A nested loop is simply a loop within a loop. An example of such a loop is where you wish to traverse a two-dimensional array. The simplest way to traverse such a structure is to use a loop to traverse each row and a nested loop to traverse the elements within each row.

int a[4][5]; // a 4x5 array of integers (4 rows, 5 columns).

// ...

for (row=0; row<4; ++row) // traverse rows

{

for (col=0; col<5; ++col) // traverse columns

{

std::cout << a[row][column] << ", "; // print value at current row and column

}

std::cout << endl; // keep each row on a separate line

}

User Avatar

Wiki User

10y ago

What else can I help you with?

Continue Learning about Engineering

How is a while loop different from a do until loop in gml?

In any programming language, a "while" loop and a "do until" loop are the same except for 1 difference. In order to enter a while loop, the condition must always be true. But in a do until loop, if the condition was false, the block of code inside the loop will always be ran at least once. Example: while (false) { // code here } in this example, the code inside the while loop will never run, but in the following example: do { //code here } until(false) although the condition is false, the code will be run 1 single time and the exists the loop.


What are the components of loop?

a loop consist of data initialization;test condition;updation; example a for loop for(int a=1;a&lt;5;a++) the loop will be executed 5 times four positives result and the last test condition will be failed and the loop will be exited there are many loops some of them are while loop,do...while loop,for loop,maybe more...... do while is an exit check loop and while and for are entry check loop.


Example of critical loop in ladder logic?

QXth+werr*&amp;J.klh%523 is the critacal loop. So take that! HA!


How do you determine which is outer loop or inner loop of the Baltimore beltway?

The outer loop goes counter clockwise, while the inner loop goes clockwise. For example, if you're driving from Fairfax, VA to Washington, DC you're going on the inner loop, and on the way back you're taking the outer loop.


What time of loop is used when you know how many times the loop instructions should be processed?

It's best to use a for loop.For example, if you want 10 iterations:for (int i = 1; i

Related Questions

What is a nested loop in java?

A nested loop is a (inner) loop that appears in the loop body of another (outer) loop. The inner or outer loop can be any type: while, do while, or for. For example, the inner loop can be a while loop while an outer loop can be a for loop.


How is a while loop different from a do until loop in gml?

In any programming language, a "while" loop and a "do until" loop are the same except for 1 difference. In order to enter a while loop, the condition must always be true. But in a do until loop, if the condition was false, the block of code inside the loop will always be ran at least once. Example: while (false) { // code here } in this example, the code inside the while loop will never run, but in the following example: do { //code here } until(false) although the condition is false, the code will be run 1 single time and the exists the loop.


Is automobile cruise control open or closed loop?

A cruise control is an example of a closed loop servo.


What are the index variable in the for loop?

The for loop uses a counter or an index variable to loop through the statements. This variable is used through the loop, changed and finally compared with the loop condition for consideration of the loop's next cycle. The variable(s) used inside the for loop for comparison (with the mentioned condition) and increment/decrement is know as the index variable. for example (Java) : for(int i=1; i&lt;5; i++){ ... } in this example, integer 'i' is the index variable.


What is the definition of 'nested' in C programming?

In C a structure within a structure is called nested. For example, you can embed a while loop in another while loop or for loop in a for loop or an if statement in another if statement.


What are the example of a open loop con?

old systems


What are the components of loop?

a loop consist of data initialization;test condition;updation; example a for loop for(int a=1;a&lt;5;a++) the loop will be executed 5 times four positives result and the last test condition will be failed and the loop will be exited there are many loops some of them are while loop,do...while loop,for loop,maybe more...... do while is an exit check loop and while and for are entry check loop.


Where do you get loop the loop straws?

C, for loops, while loops, and do while loops are control structures forFor example, the following programs are functionally identical: While loop


Can while loop and for loop give different outputs?

Sure. Here is an example: for (i=0; i&lt;3; ++i) printf ("I am for loop, i=%d\n"); i=1; while (i&gt;0) { printf ("I am while loop, i=%d\n"); i &lt;&lt;= 1; }


Example of critical loop in ladder logic?

QXth+werr*&amp;J.klh%523 is the critacal loop. So take that! HA!


What is CPU usage small programm c plus plus?

Example: int main (void) { LOOP: goto LOOP; }


What is computing in science?

Nesting is the process of organizing information in layers. For an example, a loop in a program can contain another loop which can contain yet another loop. This is called nested loops.