Arithmetic, Relational & Boolean Operations Flashcards
All 15 cards in this deck
What does the arithmetic operator
MODreturn?e.g.
11 MOD 3The remainder after integer division.
11 MOD 3=What does the arithmetic operator
DIVreturn?e.g.
11 DIV 3The whole-number part of a division (remainder discarded).
11 DIV 3=In AQA pseudo-code, what do the relational operators
≠,≤and≥mean?≠is not equal to,≤is less than or equal to, and≥is greater than or equal to.True or false? The
/operator always gives a whole-number answer.False.
/is real division and can give a decimal result, e.g.7 / 2= 3.5.DIVgives the whole-number part, e.g.7 DIV 2= 3.True or false? In
x ← 5 + 2 * 3, the multiplication is done before the addition.True. Normal arithmetic precedence applies, so
xis 11.Name the three common Boolean operators.
AND, OR and NOT.
When is a condition joined by AND true?
Only when both conditions are true.
When is a condition joined by OR true?
When at least one of the conditions is true.
What does the Boolean operator NOT do?
e.g.
NOT (age > 18)Reverses the result of a condition.
NOT (age > 18)is true when age is 18 or less.How do you write a selection statement that runs only when two conditions are both met?
e.g. age is at least 13 and member is True
Join the two conditions with AND:
IF age ≥ 13 AND member = True THEN
…ENDIFIn what order are the Boolean operators evaluated in a condition?
Brackets first, then NOT, then AND, then OR.
True or false? In
IF total + 5 > 20 THEN, the comparison>is checked before the addition.False. Arithmetic is done first, so
total + 5is worked out and then compared with 20.How can
MODbe used to test whether a whole number is even?e.g. a number stored in
nn MOD 2 = 0is true whennis even, because an even number leaves no remainder when divided by 2.What type of value does a comparison such as
score > 50give?A Boolean value: True or False.
What is the difference between
age < 18andage ≤ 18?≤includes the boundary value but<does not. Whenageis 18,age < 18is False butage ≤ 18is True.