Review
So you think you can count?
15. The modulo operator (%)
Rounding functions and more
Review and practice

Instruction

Okay. There is one more useful operator related to division: the modulo operator (%). It returns the remainder of one number divided by another number, like this:

x % y

For instance, 9 % 7 will return 2, because 9 / 7 is 1 with 2 as the remainder. This operator works with integer and decimal numbers.

Shall we try the modulo operator in an exercise?

Exercise

In our game, you can increase your strength by 1 if you sacrifice 7 HP. For each character, show its name and calculate how many health points will be left if the player decides to sacrifice the maximum number of HP. Name the column HPLeft.

Stuck? Here's a hint!

Use HP % 7.