answersLogoWhite

0

How do i do a while loop inside my current loop?

Updated: 8/20/2019
User Avatar

Wiki User

12y ago

Best Answer

while(predicate1) {

while(predicate2) {

...

}

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do i do a while loop inside my current loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

A magnet inside a wire loop can produce a current?

Only while the magnet is entering or leaving the loop. If you hold it still, no current is generated. The same goes for a longer magnet where the loop is being moved, but the magnet always remains inside the loop; no current.


Why if the same current flows in a wire coil and a single wire loop the magnetic field inside the coil is stronger than the field inside the loop?

why, if the same current flows in a wire coil and a single loop, the magnetic field inside the coil stronger than the field inside the loop


Conditional statement inside a conditional loop?

int i = 100; while(i > 0) { // Conditional loop --i; if((i % 2) == 0) { // Conditional statement inside a conditional loop System.out.println(i + " is even."); } }


Why you use for loop inside switch statement?

Because you have to repeat something. (Or you can use while-loop, too.)


Why you need a for loop when you have already while loop or do while loop?

We need a for loop because the while and do-while loops do not make use of a control variable. Although you can implement a counter inside a while or do-while loop, the use of a control variable is not as self-evident as it is in a for loop. Aside from the use of a control variable, a for loop is largely the same as a while loop. However, it is quite different to a do-while loop, which always executes at least one iteration of the loop before evaluating the conditional expression. In a for and while loop, the conditional expression is always evaluated before entering the loop, which may result in the loop not executing at all.


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.


The Do-While loop is what type of loop?

The do loop is similar to the while loop, except that the expression is not evaluated until after the do loop's code is executed. Therefore the code in a do loop is guaranteed to execute at least once. The following shows a do loop in action: do { System.out.println("Inside do while loop"); } while(false); The System.out.println() statement will print once, even though the expression evaluates to false. Remember, the do loop will always run the code in the loop body at least once. Be sure to note the use of the semicolon at the end of the while expression.


How do you convert a while loop to do-while loop?

A for loop is classified as an iteration statement. A simple example might be... For x = 1 To 10 'loop body Next x The same loop expressed as a while loop (classified as a control flow statement) could be... x = 0 Do While x < 11 'loop body x = x + 1 Loop .


What is the difference between while loop and for loop in matlab?

A while loop executes code inside the while block continuously until the said condition is not true. A for loop contains three parts. The first part is carried out prior to the for loop, the middle part is executed by the for loop until it is no longer true, and the final part is performed at the end of each go round of the loop.


How can you define null statement in loop in C programming?

If you are using for loop for(;;); or you can also define condition and iterations but the loop has to close there itself without any statement inside it. In the similar way you can define while and do while loop without any statement.


What is the difference between a for loop and a while loop in java?

ComparisonThe conditions for both the 'while' and 'for' loop are exactly the same, but in each flow structure the conditions are placed in different locations. A 'for' loop places the full condition within the 'for' loop whereas the 'while' loop places the counter variable outside of the loop.The 'for' loop is used when the length of the loop is known whereas the 'while' loop is usually used when the length of the loop is unknown.'for' loop exampleWithin the parentheses the complete condition is contained. The condition has 3 parts delimited by a colon ';'. The first part sets the counter 'int i' to 0, the second part tells the loop to stop when the counter is 5. The third part tells java to increment the counter by 1 value each time the loop iterates.for ( int i = 0; i < 5; i++)'while' loop exampleWith the 'while' loop the counter is initialized outside of the 'while' loop. Inside the parentheses of the loop the condition is set to stop looping when the counter reaches a value of 5. Inside of the 'while' loop block the counter is set to increment by 1 value each time the loop iterates.int i = 0;while ( i < 5 ) {i++}


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.