Or
Explain pretest and posttest loops in C language with syntax and an example each
C: Ch.
Answers
Answer:
statements, you make them stand out from the surrounding code.
This helps you to identify at a glance the statements that are conditionally
executed by a loop.
2. A pretest loop tests its condition before each iteration. A posttest loop tests its
condition after each iteration. A posttest loop will always execute at least once.
3. Because they are only executed when a condition is true.
4. The while loop is a pretest loop and the do-while loop is a posttest loop.
5. The while loop.
6. The do-while loop.
7. The for loop.
8. A counter variable is used to control or keep track of the number of times a loop
iterates. In a loop, the counter is usually incremented or decremented. If the
counter variable is not properly initialized, it will not hold the correct number.
9. An accumulator is used to keep a running total of numbers. In a loop, a value is
usually added to the current value of the accumulator. If it is not properly
initialized, it will not contain the correct total.
10. Because the for loop has an update expression that normally changes the
Explanation: