Let’s print only odd pages.
- Replace the operation of increasing the page number from
page += 2.
- Change the number of pages from
Look at how quickly you are getting along! Let’s remember what else a printer should be able to do:
The new printer is simple enough, it should be able to print
all the pages in directand reverse order, print even and odd pages and make copies of one page.
All we have to do is print even and odd pages. Printing only odd pages is easy:
2, and not by
Perhaps you already noticed that in loops, an increase or decrease of variables by some number is regularly used. And we constantly have to write cumbersome structures, such as
|Increment (increase by one)|
|Decrement (decrease by one)|
You can combine not only addition, but also other mathematical operations: subtraction
/= and calculating the remainder
%=. For example,
i *= 10 will do the same as
i = i * 10.