levo

Fundamentals of Programming

Arithmetic operations

  • 3 things to know
  • Paper 1
Start revising · £5/month

Overview

Recall questions on real division against integer division, DIV and MOD, the type each operation returns, and the packing problems the remainder is used to solve.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Process

Which arithmetic operations does a program need, and how do they group?

Process

What is 17 MOD 5, and how do the quotient and remainder relate back to the original number?

Key term

What does rounding do? Give the results of rounding 4.6 and 4.4 to the nearest whole number, and 3.14159 to two decimal places.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Which arithmetic operations does a program need, and how do they group?

    Model answer

    Four are the ordinary operations of arithmetic: adding, subtracting, multiplying and dividing. Division splits into two, because a computer must be told which kind is wanted — real division gives a fractional result, while integer division discards the fraction and leaves a separate remainder alongside the quotient. Raising to a power is the fifth operation. The last two do not calculate at all but control precision: rounding adjusts a value to the nearest step, while truncation simply cuts the unwanted digits away, which is why the two disagree on a value such as −3.7.

  2. 2

    What type of result do addition, subtraction and multiplication give?

    Model answer

    Applied to two integers each gives an exact integer result. If either operand is a real, the result is a real. Multiplication and addition of large integers can overflow if the result will not fit in the storage allowed for the type.

  3. 3

    What does real (float) division give, and what is 7 / 2?

    Model answer

    It gives the full quotient including any fractional part, so 7 / 2 = 3.5. The result is a real even when it happens to have no fractional part, so 6 / 3 gives 3.0 rather than the integer 3 in most languages.

  4. 4

    What does integer division give, and what is 17 DIV 5?

    Model answer

    It gives only the whole number of times the divisor goes into the dividend, discarding any fractional part, so 17 DIV 5 = 3.

  5. 5

    What is 17 MOD 5, and how do the quotient and remainder relate back to the original number?

    Model answer

    17 MOD 5 = 2. The remainder is what is left over after the whole divisions, so divisor x quotient + remainder returns the original: 5 × 3 + 2 = 17. When the operands are positive the remainder is always at least 0 and less than the divisor.

  6. 6

    Contrast integer division with real division using 22 and 7.

    Model answer

    Real division gives 22 / 7 = 3.142857..., a real value with a fractional part. Integer division gives 22 DIV 7 = 3 with 22 MOD 7 = 1, two exact whole numbers. Real division answers how much each share is worth; integer division answers how many whole shares there are and what is left over.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A driver is .
softwarehardwarestorage

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

Head means the first single element of a non-empty list.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Fundamentals of Programming, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.