COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
while loop
|
|
for loop
|
|
do while loop
|
|
All of the mentioned
|
Detailed explanation-1: -The “do-while” loop is most suitable to first perform the operation and then test the condition. In the do while loop the condition is checked at the bottom of the loop. Hence even if the condition is false the loop will execute at least one time.
Detailed explanation-2: -However a while loop will test the condition before the code within the block is executed. This means that the code is always executed first and then the expression or test condition is evaluated.
Detailed explanation-3: -In the do-while loop, the body of a loop is always executed at least once. After the body is executed, then it checks the condition.
Detailed explanation-4: -while loop vs do-while loop in C. 1. While the loop is an entry control loop because firstly, the condition is checked, then the loop’s body is executed. The do-while loop is an exit control loop because in this, first of all, the body of the loop is executed then the condition is checked true or false.
Detailed explanation-5: -Sequential loop is used when we are sure about how many times a loop body will be executed.