answersLogoWhite

0

Do loop example

Updated: 8/10/2023
User Avatar

Wiki User

14y ago

Best Answer

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

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

Wiki User

14y ago

When someone says something like "I got stuck in this do loop with my insurance company" they're saying that they're getting the runaround -- any frustrating never-ending situation. The origin of the phrase "do loop" is from computer programming. There are ways to write a program that repeats a set of instructions until some goal is accomplished. Because these are written as as some variation on "DO { some actions } UNTIL { goal is met }" they are called "Do loops". A common programming hazard is to construct such a loop without proper logic for deciding when "goal is met", so that the loop never ends.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

give me some of the example program of programing

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Do loop example
Write your answer...
Submit
Still have questions?
magnify glass
imp
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.