answersLogoWhite

0


Best Answer

As many times as necessary. There is no practical limit because all loops rely on a control expression that can only evaluate true or false. So long as the control expression evaluates true, the loop will just keep iterating. The canonical example is the infinite loop:

while (true) {

// ...

}

The control expression never evaluates false, so the only way to break out of this loop is from within the body of the loop itself. Although we typically use infinite loops when the control expressions are far too complex to be expressed as a simple expression in the while statement, we can easily avoid this by placing those control expressions in a function. For example, if the control expressions depend on three variables, a, b, c, we can pass those variables to a predicate function that returns true or false:

while (evaluate (a, b, c));

Here, the overall complexity of the control expression is hidden within the evaluate function, greatly simplifying the calling code.

User Avatar

Wiki User

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

Wiki User

12y ago

Zero or more.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How many times will a for loop be executed?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the minimum number of times a do- while loop is executed?

A do while loop is executed at least one time.


Difference between do while and for loop?

for loop it consists of 3 parts 1. initialization 2. condition 3. incrementation like for(i=1;i<=10;i++).This loop executes 10 times. While loop: This is an entry check loop. First it checks for the condition and if the condition is true then only loop will be executed and this continues till the condition becomes false. ex: i=0; while(i<10) {i++; } This loop executes 10 times. Do loop: This is an exit check loop. This executes the loop at least once even when the condition is false. ex: 1=0; do { i++; }while(i<10);


What are the components of loop?

a loop consist of data initialization;test condition;updation; example a for loop for(int a=1;a<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.


What are the statements executed within a loop collectively known as?

The body of the loop.


What the difference between pretest loop and posttest loops?

The difference is that pre means before and post means after in Latin so it's tested before or after. :)


Why are the statements in the body of a loop called conditionally executed statements?

These statements are called conditionally executed statements because the may or may not be executed. They will be executed while the boolean (true/false) statement in the beginning of the loop is true, but will not be executed when statement is false.


List out the differences between while and dowhile statement?

The do ..while loop is executed at least once, whereas the while loop may not be executed even once.


When would you use a count controlled loop vs. a flag controlled loop?

Counter Loop:Counter loop is a loop which executes statement up to a fixed number of time.In GW FOR ... NEXT loop is used as counter loop.Controlled Loop:Controlled loop is used to extend the statements till a specific condition is satisfied. In GW WHILE ... WEND is used as controlled loop.


How many times is ado while loop guaranteed for a loop?

one or more


Definition and comments for loop?

The C and C++ for loop is defined as...for (init-expression; test-expression; loop-expression) loop-statement;The init-expression is executed once.At the top of the loop, test-expression is evaluated. If it is false, control passes to the statement following loop-statement.The loop-statement is executed. It may be one statement, it may be a block of statements, or it may be no statement. If it is no statement, the semi-colon is required.At the bottom of the loop, loop-expression is executed, and then control passes to the test-expression at the top of the loop for another go-around.Each of init-expression, test-expression, and loop-expression may be missing. The semi-colons are required. The formal "forever" loop is for (;;) loop-statement; in which case the only way out is the break statement.Since each of init-expression, test-expression, and loop-expression can have side-effects, sometimes a loop is constructed with no loop-statement, and all processing is done between the parentheses.If test-expression is initially false, loop-expression and loop-statement are never executed. The init-expression is always executed only one time, and test-expression is executed at least one time.At any point during loop-statement, the breakstatement will exit to the statement following loop-statement, and the continue statement will jump to the loop-expression at the bottom of the loop.


Is do-while loop executed only if the condition is true?

First the body is executed, then the condition gets checked.


What do you mean by prime a loop?

prime a loop is that how mach time it executed either max time or minimum time