Module: cycles. Loop with parameter (for)


Problem

4/17

for loop header - features

Theory Click to read/hide

The head of a for loop in Pascal consists of several parts:
1) the word for
2) what variable and what value are we assigning. In this program, this is b := 1, i.e. we assign the value 1 to b.
3) the word to or downto, which indicates the step with which the loop is executed. If we write to, then the variable will increase by 1 every iteration, if downto, then decrease by 1.
4) final value of the variable
5) word do
6) the word  begin  (it can be omitted if there is only one line in the loop body, otherwise it must be written. If you do not write begin, then only the first line will be executed from the entire body of the loop). Let's not forget after the loop body, if we wrote the word begin, write the word end; !

Problem

Change the loop header and assign a value to the variable i so that the variable b  is present in the loop header. and the values ​​of two variables i and b were displayed on the screen
The value of variable i must change from 1 to 5, and the value of variable b from 5 to 1
The output should be like this:
15
24
3 3
4 2
5 1
Note that you only have to change the value of the variable i and the head of the loop, in which the variable b should remain!