Task 3 of 14 · 0 solved · 14 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

1.4 Arithmetic — the remainder operator %

Lesson

The remainder operator %

% gives the remainder after integer division — what is left over. 7 % 3 is 1 (because 7 = 2×3 + 1). It is handy for tests like even/odd: n % 2 is 0 for even numbers.


Worked example

System.out.println(7 % 3);   // 1
System.out.println(10 % 2);  // 0
System.out.println(9 % 5);   // 4

▶ Try it: run this, then change something and run it again.



What is 7 % 3?


Type exactly what this prints:

System.out.println(10 % 2);

What is 9 % 5?


Match each expression to its result.