Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

With a loop, you can indicate the starting value for the loop control variable,

ID: 3780949 • Letter: W

Question

With a loop, you can indicate the starting value for the loop control variable, the test condition that controls loop entry, and the expression that alters the loop control variable, all in one convenient place. do for do-while while The do-while loop is a(n) loop. Intest pretest posttest forest A while loop is a(n) loop. fortest intest pretest posttest Which loop is most convenient to use if the loop body must always execute at least once? a do loop a while loop an if loop a for loop The loop control variable ii cheeked at the bottom of which kind of loop? a for loop a do loop awhile loop all of the above

Explanation / Answer

1. for
The for loop goes as follows
for(part1;part2;part3)
{
// The code//
}
Explaination:
part1: The part 1 contains the initialization of the loop variable, that is it indicates the starting value of the variable in the loop.
part2: The part 2 contains the condition for the loop variable that controls the loop entry. It tests the condition and decide the loop entry or exit.
part3: The part 3 is the increment/ decrement of the variable. That is it is the part that alters the expresion or the variable used in the loop.

2.post test
The do-while loop is a post test loop because the do while loop is a control flow statement, which executes the block of code at least once, and then checks the boolean condition and then repeats the execution of the code until the condition becomes false. Thus, as the condition is checked after once the code is executed, so it is called as a post test loop.

3.pre test
The while loop is pre test loop because the while loop is a control flow statement, which first checks the boolean condition and then executes the block of code, until the condition gets false. Thus it is a post test loop.

4.a do loop
A do while loop is a post test loop, thus once the block of code is executed and then the condition is checked. So always an output is executed at least once irrelevant of the condition to be true or false, in a do while loop. But in case of while loop, if the condition is false, no output is produced. In the if condition, if the condition is false then no output is produced. And in the case of for loop, after the initialization, if the condition is false, then the loop is terminated and no output is produced.

5.a do loop
The do loop is a bottom tested loop, because it executes the block of code at least once. Instead of checking the condition at top, the checking of condition is done at the bottom.   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote