Arithmetic, Logical & Boolean Operators (CIE IGCSE Computer Science)

Revision Note

Test Yourself
Becci Peters

Expertise

Computer Science

Arithmetic Operators

  • Addition (+): Adds two values together
  • Subtraction (-): Subtracts one value from another
  • Division (/): Divides one value by another
  • Multiplication (*): Multiplies two values together
  • Exponentiation (^): Raises a number to a power
  • Modulo (MOD): Returns the remainder of a division operation
  • Integer Division (DIV): Returns the whole number of a division operation

Pseudocode example:

a 5

b 3

c a + b

d a - b

e a * b

f a / b

g a MOD b

h a ^ b

i a DIV b

Python example:

a = 5

b = 3

c = a + b

d = a - b

e = a * b

f = a / b

g = a % b

h = a ** b

i = a // b

Java example:

int a = 5;

int b = 3;

int c = a + b;

int d = a - b;

int e = a * b;

double f = (double) a / b;

int g = a % b;

double h = Math.pow(a, b);

int i = a / b;

Visual Basic example:

Dim a As Integer = 5

Dim b As Integer = 3

Dim c As Integer = a + b

Dim d As Integer = a - b

Dim e As Integer = a * b

Dim f As Double = a / b

Dim g As Integer = a Mod b

Dim h As Double = Math.Pow(a, b)

Dim i As Integer = a \ b

Logical Operators

  • Equal to (=): Returns true if two values are equal
  • Less than (<): Returns true if the first value is less than the second value
  • Less than or equal to (<=): Returns true if the first value is less than or equal to the second value
  • Greater than (>): Returns true if the first value is greater than the second value
  • Greater than or equal to (>=): Returns true if the first value is greater than or equal to the second value
  • Not equal to (<>): Returns true if two values are not equal

Pseudocode example:

a 5

b 3

c (a = b)

d (a < b)

e (a <= b)

f (a > b)

g (a >= b)

h (a <> b)

Python example:

a = 5

b = 3

c = (a == b)

d = (a < b)

e = (a <= b)

f = (a > b)

g = (a >= b)

h = (a != b)

Java example:

int a = 5;

int b = 3;

boolean c = (a == b);

boolean d = (a < b);

boolean e = (a <= b);

boolean f = (a > b);

boolean g = (a >= b);

boolean h = (a != b);

Visual Basic example:

Dim a As Integer = 5

Dim b As Integer = 3

Dim c As Boolean = (a = b)

Dim d As Boolean = (a < b)

Dim e As Boolean = (a <= b)

Dim f As Boolean = (a > b)

Dim g As Boolean = (a >= b)

Dim h As Boolean = (a <> b)

Boolean Operators

Boolean operators are logical operators that can be used to compare two or more values and return a Boolean value (True or False) based on the comparison. There are 3 you need to know:

  • AND: Returns True if both conditions are True
  • OR: Returns True if one or both conditions are True
  • NOT: Returns the opposite of the condition (True if False, False if True)

Boolean Operators in Pseudocode:

IF (condition1 AND condition2) THEN

// code to execute if both conditions are True

END IF

IF (condition1 OR condition2) THEN

// code to execute if one or both conditions are True

END IF

IF NOT(condition) THEN

// code to execute if the condition is False

END IF

Boolean Operators in Python:

if condition1 and condition2:

# code to execute if both conditions are True

if condition1 or condition2:

# code to execute if one or both conditions are True

if not condition:

# code to execute if the condition is False

Boolean Operators in Java:

if (condition1 && condition2) {

// code to execute if both conditions are True

}

if (condition1 || condition2) {

// code to execute if one or both conditions are True

}

if (!condition) {

// code to execute if the condition is False

}

Boolean Operators in Visual Basic:

If condition1 And condition2 Then

' code to execute if both conditions are True

End If

If condition1 Or condition2 Then

' code to execute if one or both conditions are True

End If

If Not condition Then

' code to execute if the condition is False

End If

Exam Tip

  • Boolean operators are often used in conditional statements such as if, while, and for loops
  • Boolean operators can be combined with comparison operators such as == (equal to), != (not equal to), < (less than), > (greater than), <= (less than or equal to), and >= (greater than or equal to)
  • Be careful when using the NOT operator, as it can sometimes lead to unexpected results. It is always a good idea to test your code with different inputs to ensure that it works as expected

You've read 0 of your 0 free revision notes

Get unlimited access

to absolutely everything:

  • Downloadable PDFs
  • Unlimited Revision Notes
  • Topic Questions
  • Past Papers
  • Model Answers
  • Videos (Maths and Science)

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

Becci Peters

Author: Becci Peters

Becci has been a passionate Computing teacher for over 9 years, teaching Computing across the UK helping to engage, interest and develop confidence in the subject at all levels. Working as a Head of Department and then as an educational consultant, Becci has advised schools in England, where her role was to support and coach teachers to improve Computing teaching for all. Becci is also a senior examiner for multiple exam boards covering GCSE & A-level. She has worked as a lecturer at a university, lecturing trainee teachers for Computing.