Arithmetic Operators

Computer Science: OCR GCSE, topic 2.2.6

Arithmetic Operators

Operators are symbols that represent a specific function within a program.

Basic operators

Basic operators

  • Addition is done using a + sign.
  • Subtraction is done using a - sign.
  • Division is done using a / sign.
  • Multiplication is done using a * sign.
  • Exponentiation is done using a ^ or ** sign.
Modulo operator

Modulo operator

  • The modulo operator gives the remainder of the division of two numbers.
  • For example:
  • 5 MOD (or %) 2 would be equal to 1. That's because 5 ÷ 2 = 2 remainder 1.
  • 43 MOD 9 would be equal to 7. That's because 43 ÷ 9 = 4 remainder 7.
Integer division

Integer division

  • The integer division operator returns the quotient (whole part) of a division.
  • For example:
  • 5 DIV (or //) 2 would give 2.
  • 43 DIV 9 would give 4.

Test yourself on Arithmetic Operators

  • What is the result of 17 MOD 5 (modulo operation)?

  • Which of the following statements are correct of arithmetic operators?

  • The DIV operation performs which operation?

Practise this topic for free