Skip to content
Physics and Astronomy
Home Our Teaching Resources C programming Quiz: integer division
Back to top

Quiz 1 - integer division

To be completed before the first lecture of week 2.

When we were at school, before we knew about fractions, we would say "seven divided by two is three remainder one". Then we learnt about fractions and promptly forgot about the "remainder" idea.

Well now we need to remember it again! And rather than just remembering it and forgetting it again thirty seconds later we're going to a use it a few times so that it will stick in our head.

In C, as in most computer programming languages, there's no one operator that gives both numbers (integer result and remainder) simultaneously, instead we use "/" for the integer part of the divisor and "% " for the remainder. So in the above example:

7 / 2 = 3 (not 3.5!)
7 % 2 (seven remainder two) = 1

This reminder exercise has the form of a quiz which you may either do on your own or with a partner. It may be done on any web browser.

One person Two person
No game, just a score Single player hangman Hangman Connect 4
                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Privacy & cookies Share
Back to top