answersLogoWhite

0


Best Answer

If you mean how do you simultaneously execute 2 for loops, you cannot. At best you can execute 2 for loops concurrently, where each loop executes (independently) within two separate threads.

It is possible to execute two loops within the same statement, however this is really just one loop based upon two conditions:

int x, y;

for (x=0, y=0; x<100 && y<100; ++x, ++y) {

/* ... */

}

You probably mean how do you execute a loop within a loop (a nested loop). this is achieved as follows:

int x, y;

for (x=0; x<100; ++x) {

for (y=0; y<100; ++y) {

/* ... */

}

}

Note that the body of this loop will execute 100 x 100 = 10,000 times.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you execute 2 for loops together?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the difference between bounded loop and unbounded loop in programming?

Bounded loops are also known as counting loops because they will iterate a pre-determined number of times before terminating. For example: for x=1 to 15 print x next x Here, the variable x is incremented by 1 at the end of each iteration, thus the loop execute 15 times in total. Unbounded loops are not defined by a specific count, but by some other condition. Unbounded loops are often called infinite loops, however there must always be an exit condition that is reachable. x = rand() while x&lt;&gt;0 print x x = rand() end while Here, x is set to some random value. So long as x is non-zero, its value will print and x will be set to another random value. The loop may not execute at all (if x is initially zero), but once started it is not known how many times it will iterate until the exit condition is satisfied.


Difference between deterministic and nondeterministic loop?

Deterministic and non-deterministic loops A deterministic loop is predictable. The number of iterations of such a loop are known in advance, even before the loop has started. Most counting loops are deterministic. Before they start, we can say how many times they will execute. A non-deterministic loop is not easily predicted. A loop that is driven by the response of a user is not deterministic, because we cannot predict the response of the user. Non-deterministic loops usually are controlled by a boolean and the number of iterations is not known in advance.


What is meant by zero overhead loop?

the term zero over head looping means that the processor can execute loops without consuming cycles to test the value of loop counter , perform a conditional branch to the top of the loop and decrement the loop counter.


Does SGID allow users to execute a binary compiled program?

Not, the execute bit does that.00100 - execute for user00010 - execute for group00001 - execute for others04000 - set-uid02000 - set-gid


C programs using loops?

Loops are very important part of a C-language. If we have to run our programe multiple time then we use Loops of C.

Related questions

What is meant by for loop in C programming?

loops execute a set of insructions repeatedly for a certain numbers of times..


What is a description of how to do k2togtbl and p2togtbl for knitting a sweater?

Knit two together through the back loops and Purl two together through the back loops


What is repetation structure?

Repetitive control structures are loops like the do while loop and the for loops. They repeat and execute the same set of instruction until the condition stated in the while or for loop ceases to be true. After which it will exit the loop and continue down the program.


What does double crochet 2 together means?

In US notation, it means insert hook into first stitch, (yoh and pull up a loop, yoh and pull up a loop through 2 loops). Leaving 2 loops on hook, insert hook into next stitch and repeat the section in brackets. Finally yoh and pull through all loops on hook. This has the effect of reducing your stitches by one.


What is repetition control structure?

Repetitive control structures are loops like the do while loop and the for loops. They repeat and execute the same set of instruction until the condition stated in the while or for loop ceases to be true. After which it will exit the loop and continue down the program.


What does dc3tog mean in crochet pattern?

This means double crochet 3 together. It is a decrease over 3 stitches. yarn over (yo), insert hook in stitch, yo and pull through, yo and draw through 2 loops (2 loops on hook) yo, insert hook in next st, yo and pull through, yo, draw through 2 loops (3 loops on hook) yo, insert hook in next st,yo and pull through, yo and draw through 2 loops (4 loops on hook) yo and draw through all 4 loops.


What does s2tog mean in crochet?

Assuming this is a US pattern: 1. insert hook into next stitch, yoh (yarn over hook) and draw through stitch (2 loops on hook) 2. insert hook into next stitch, yoh and draw through stitch (3 loops on hook) 3. yoh and draw through all three loops on hook.


How many loops are in a frogs circulatory system?

A birds circulatory system consists of two loops.


How do you buckle a belt with two loops?

Buckling a belt with 2 loops is actually quite simple. Just run the open end through the 2 loops and bring it back around through the second loop.


In crochet, what does 'tog' mean?

Half Double Crochet Together .. also seen as hdc2togIn American Terms, work as follows:yarn over (pick up yarn with hook)insert hook into next stitchyarn overpull through (pull up a loop)you will have 3 loops on your hookYarn overinsert hook into next stitchyarn overpull throughyou will have 5 loops on your hookyarn overpull through all 5 loops on hook


How do you do a sc together stitch in crochet?

This is probably sc2tog, which means single crochet 2 together. Insert hook through next stitch, yoh and pull through stitch, insert hook through next stitch, yoh and pull through stitch (3 loops on hook), yoh and pull through all 3 loops.


How many loops in a mammals circulatory system?

it has 2 LOOPS ;)... ACCORDING TO THE BOOK