Computer Science, asked by brianaw121, 18 days ago

The difference between a for loop and a while loop is that a for loop is a loop that happens for a certain number of times. A while loop happens until a certain condition is met. How do you know when to use each one? Give specific examples in your answer.

Answers

Answered by ifraajmal163
0

Answer:

when you know the number of times you want to use loop-- use for loop

when you only know the condition and don't know the exact number of iteration a loop will cover --- use while loop

Answered by Najibm5441
2

Answer:

The for loop do have all its declaration (initialization, condition, iteration) at the top of the body of the loop. Adversely, in while loop only initialization and condition is at the top of the body of loop and iteration may be written anywhere in the body of the loop.The For Loop differs from the While Loop in that the For Loop executes a set number of times. A While Loop stops executing the subdiagram, only if the expected value at the conditional terminal exists. In LabVIEW, the WHILE Loop is located on the Functions>>Programming>>Structures palette.

Similar questions