Arithmetic, Relational & Boolean Operations Flashcards

All 15 cards in this deck

What does the arithmetic operator MOD return?

e.g. 11 MOD 3

The remainder after integer division.
11 MOD 3 = 22

What does the arithmetic operator DIV return?

e.g. 11 DIV 3

The whole-number part of a division (remainder discarded).
11 DIV 3 = 33

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. DIV gives 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 x is 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
…
ENDIF

In 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 + 5 is worked out and then compared with 20.

How can MOD be used to test whether a whole number is even?

e.g. a number stored in n

n MOD 2 = 0 is true when n is even, because an even number leaves no remainder when divided by 2.

What type of value does a comparison such as score > 50 give?

A Boolean value: True or False.

What is the difference between age < 18 and age ≤ 18?

≤ includes the boundary value but < does not. When age is 18, age < 18 is False but age ≤ 18 is True.