Arithmetic operators Flashcards
What are arithmetic operators used for?
to specify how values are to be manipulated
to perform calculations in algorithms and programs
(OCR pseudocode)
+
addition
e.g. 13 + 9 = 24
(OCR pseudocode)
-
subtraction
e.g. 24 - 12 = 13
(OCR pseudocode)
*
multiplication
e.g. 6 * 9 = 54
(OCR pseudocode)
/
division
e.g. 36 / 5 = 5.2
(OCR pseudocode)
MOD
modulus division
Returns the remainder after the division of one number by another
e.g. remainder = number MOD 2
number / 2
(OCR pseudocode)
DIV
Quotient division
Returns the quotient/lowest integer/whole number
e.g. 11 DIV 4 = 2
(OCR pseudocode)
Exponential powers of
e.g. 3 ^ 3 = 27
Order of operations
the order of operations needs to be followed in a calculation
Brackets Indices or powers Division Multiplication Addition Subtraction
A chocolate factory worker puts 20 bars into each box.
Write an algorithm to calculate and output the number of full boxes produced in a day. [2]
numberOfBars = input ("Enter number of bars produced.") numberOfBoxes = numberOfBars DIV 20
print(numberOfBoxes + “full boxes have been produced.”)
Wife an algorithm in pseudocode that would allow a user to:
- input the number of items sold by a shop each day for three days
- calculate the total number of items sold
- calculate the mean number of items sold each day as an integer. [3]
day1 = input ("Please enter number sold on day 1") day2 = input ("Please enter number sold on day 2") day3 = input ("Please enter number sold on day 3") total = day1 + day2 + day3 meanSold = total DIV 3