Computer Science, asked by bhaktipatel3413, 10 months ago

Explain about while loop and for each loop with diagrams

Answers

Answered by Anonymous
0

Because the while loop checks the condition/expression before the block is executed, the control structure is often also known as a pre-test loop. Compare this with the do while loop, which tests the condition/expression after the loop has executed.

Answered by XxDazzledSweetiexX
25

Question

Explain about while loop and for loop with diagrams.

Answer

While loop :

The function of while loop is to execute statement or block of statements repeatedly while the test condition ( boolean expression) returns a true value. In this loop, the condition is checked at the beginning of the loop. If the condition is true, the control enters the loop and executes the body of the loop. The loop will terminate when the condition is false.

Since the condition is checked at the beginning of the loop, it is called as Entry controlled loop. This means that if the condition is not true the first time, the entire loop will be skipped and will execute zero times.

Note : The diagram is present in the attachment.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Attachments:
Similar questions