Module: cycles. Loop with parameter (for)


Problem

4/17

for loop header - features

Theory Click to read/hide

There can be multiple operators in each heading part, separated by commas.< /span>
Heading examples:

for ( int i = 0; i < 10; i + + ) { ... } - standard title

for ( int i = 0, x = 1; i < 10; i += 2, x *= 2 ){ ... }  
         // in this case, we use two variables that will change after the execution of the loop body - these are the variables i and x
         // variable i changes in increments of 2 - i+=2 - short for i=i+2
         // variable x increases by 0.1 times with each step x=x*2 - abbreviated х*=2

Problem

Change the title of the loop to display the values ​​of the two i variables and b.
The value of the i variable should change from 1 to 5, and the value of the b variable should change from 5 to 1.
The output should be like this:

1 5
24
3 3
4 2
5 1

Note, you only need to change the loop title.