Loops for CXC

preview_player
Показать описание
LOOPS IN PASCAL [repeat, iteration] = DRY [Don’t Repeat Yourself]

1. FOR LOOP: repeats a specific number of times.
a. This loop automatically initializes itself.
b. This loop automatically increments itself.
2. DO WHILE LOOP: repeats as long as a condition is true.
a. You must initialize this loop (meaning assign the variable to determine the loop a value, before the loop begins.)
b. Also increment which means to have the same variable count to determine when the loop should end so you don’t create an indefinite or infinite loop.
3. REPEAT UNTIL: is a loop which repeats as long as a condition is false.
a. It is the opposite of a DO WHILE loop. You must also increment and initialize for the same reasons as the ‘Do While Loop’.
b. This loop is also called a post-test loop, meaning the syntax to test if the program should continue occurs at the end of the loop statements.
Рекомендации по теме