answersLogoWhite

0


Best Answer

A while loop repeats until the condition becomes false, and may never execute:

int a = 4;

while (a > 5)

{

//Do something

}

or

int a = 4;

while (a > 0)

{

//Do something

a--;

}

User Avatar

Wiki User

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

Wiki User

12y ago

A "while" loop is used for the case where you want to test the exit conditional FIRST, before starting any work.

An "until" loop (which is called a "do-while" loop in Java) would be used if you want the loop body to run AT LEAST ONCE, before the exit conditional is tested.

A "for" loop is used when you need a loop iterator (that is, a loop counter). This iterator may be used to count the number of times the loop executes before terminating, or may be important to execution in the loop body. "for" loops do NOT always have a test (exit) expression that uses the iterator; if they do not, they could be written as a "while" loop with an internal counter, but it is often cleaner to use a "for" loop instead.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

A for-loop, a while-loop, and a do-while-loop.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

while and do-while

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Which pair of loops causes a statement or set of statements to repeat as long as a condition is true?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the difference between conditional statements and looping statements?

The main difference is how often they run. A conditional statement - often an IF - may or may not run. If it does (depending on whether a condition is fulfilled), it runs only once. A looping statement - often a WHILE or FOR - is designed to repeat, while a certain condition is true.


Do loops for dummies?

do <some statement here, dummy> while (<a condition here, dummy>); It will repeat the statement, and after every repetition checks the condition: if false, leaves to loop.


What is the meaning of the repeat command?

The exact meaning will depend on the language. In general, however, the repeat command will repeat a block of statements while a condition remains true (much like a do...while or for loop).


What is the repetitive control structure in c plus plus?

C provides two sytles of flow control:BranchingLoopingBranching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching: Branching is so called because the program chooses to follow one branch or another.if statementThis is the most simple form of the branching statements. It takes an expression in parenthesis and an statement or block of statements. if the expression is true then the statement or block of statements gets executed otherwise these statements are skipped.? : OperatorThe ? : operator is just like an if ... else statement except that because it is an operator you can use it within expressions. ? : is a ternary operator in that it takes three values, this is the only ternary operator C has.switch statement:The switch statement is much like a nested if .. else statement. Its mostly a matter of preference which you use, switch statement can be slightly more efficient and easier to read. Using break keyword:If a condition is met in switch case then execution continues on into the next case clause also if it is not explicitly specified that the execution should exit the switch statement. This is achieved by using break keyword. Try out given example Show ExampleWhat is default condition:If none of the listed conditions is met then default condition executed. Looping Loops provide a way to repeat commands and control how many times they are repeated. C provides a number of looping way. while loopThe most basic loop in C is the while loop.A while statement is like a repeating if statement. Like an If statement, if the test condition is true: the statements get executed. The difference is that after the statements have been executed, the test condition is checked again. If it is still true the statements get executed again.This cycle repeats until the test condition evaluates to false. for loopfor loop is similar to while, it's just written differently. for statements are often used to proccess lists such a range of numbers: do...while loopdo ... while is just like a while loop except that the test condition is checked at the end of the loop rather than the start. This has the effect that the content of the loop are always executed at least once. break and continue statements C provides two commands to control how we loop: break -- exit form loop or switch.continue -- skip 1 iteration of loop.


What is the difference between a repeat until and a while do loop?

Repeat until loops run until a condition is true. They repeat at the end of the loop and they will always run at least once. While do loops will only run while a condition is true. They may not run at all.

Related questions

What is the difference between conditional statements and looping statements?

The main difference is how often they run. A conditional statement - often an IF - may or may not run. If it does (depending on whether a condition is fulfilled), it runs only once. A looping statement - often a WHILE or FOR - is designed to repeat, while a certain condition is true.


What is the difference between Do While statements and Do For statements?

A "do while....." statement is a looping instruction to a program to repeat a stage in the program while some condition is true - e.g while a variable is negative, or, while one variable is less than another. A "do for ....." statement is a looping instruction to a program to repeat a stage in the program a set number of times - e.g for steps = 1 to 10, or, for steps = 1 to (some variable).


Explain various looping statements in java?

The for loop is commonly used to repeat a statement a certain number of times, especially if you know in advance how many repetitions you need.while will continue to repeat the statement while the condition is true.do...while is similar to while, but the condition is evaluated after the command is executed.In all of these cases, you can replace the single command with a block of code, i.e., several commands within curly braces.


When do we need to repeat an action Explain with examples from daily life?

We repeat an action as long as the condition is not true. It stop repeating the action when the condition become true with the help of REPEAT....UNTIL statement


Do loops for dummies?

do <some statement here, dummy> while (<a condition here, dummy>); It will repeat the statement, and after every repetition checks the condition: if false, leaves to loop.


What is the meaning of the repeat command?

The exact meaning will depend on the language. In general, however, the repeat command will repeat a block of statements while a condition remains true (much like a do...while or for loop).


What is a musical statement followed by a repeat of that statement and a counter statement called?

binary form


Is repeat a homonym?

no the correct statement is is homophoious


What is the repetitive control structure in c plus plus?

C provides two sytles of flow control:BranchingLoopingBranching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching: Branching is so called because the program chooses to follow one branch or another.if statementThis is the most simple form of the branching statements. It takes an expression in parenthesis and an statement or block of statements. if the expression is true then the statement or block of statements gets executed otherwise these statements are skipped.? : OperatorThe ? : operator is just like an if ... else statement except that because it is an operator you can use it within expressions. ? : is a ternary operator in that it takes three values, this is the only ternary operator C has.switch statement:The switch statement is much like a nested if .. else statement. Its mostly a matter of preference which you use, switch statement can be slightly more efficient and easier to read. Using break keyword:If a condition is met in switch case then execution continues on into the next case clause also if it is not explicitly specified that the execution should exit the switch statement. This is achieved by using break keyword. Try out given example Show ExampleWhat is default condition:If none of the listed conditions is met then default condition executed. Looping Loops provide a way to repeat commands and control how many times they are repeated. C provides a number of looping way. while loopThe most basic loop in C is the while loop.A while statement is like a repeating if statement. Like an If statement, if the test condition is true: the statements get executed. The difference is that after the statements have been executed, the test condition is checked again. If it is still true the statements get executed again.This cycle repeats until the test condition evaluates to false. for loopfor loop is similar to while, it's just written differently. for statements are often used to proccess lists such a range of numbers: do...while loopdo ... while is just like a while loop except that the test condition is checked at the end of the loop rather than the start. This has the effect that the content of the loop are always executed at least once. break and continue statements C provides two commands to control how we loop: break -- exit form loop or switch.continue -- skip 1 iteration of loop.


What is the Statement made by a jury in addition to its verdict?

In the US there are no other statements that the jury need make. Occasionally, after rendering a verdict the attorney for the losing side may request that the jury members be 'polled' individually so that they must individually repeat the verdict they rendered, but no other statement is required and they are not allowed to be questioned as to their verdict by anyone!


How does a REPEAT loop work?

The repeat loop is very simple. It allows you to repeat a statement or block of code without needing to copy-and-paste it. Here are some examples:{repeat(5){x += 15;}}{repeat(3){x += 15; y -= 5;}}The number in the parentheses dictates how many times you want to repeat the statement/code block.You may also use a variable:repeat(self.x){instance_create(irandom(400),irandom(400),object_obj);}


What is the difference between a repeat until and a while do loop?

Repeat until loops run until a condition is true. They repeat at the end of the loop and they will always run at least once. While do loops will only run while a condition is true. They may not run at all.