Understand and use arithmetic, logical and Boolean operators

Cambridge IGCSE Computer Science (0478) – Operators, Logic and Computer Systems

Learning objectives

  • Explain the main components of a computer system and how data are represented.
  • Design, develop and test simple algorithms using flowcharts, trace tables and pseudocode.
  • Identify and apply all arithmetic, relational and Boolean operators required by the syllabus.
  • Use operator‑precedence rules correctly and construct truth tables for Boolean expressions.
  • Understand basic concepts of arrays, file handling, databases and Boolean‑gate circuits.

1. Computer Systems – an overview (Syllabus Areas 1‑6)

1.1 Number systems and data representation

  • Binary (base‑2) – the language of computers; each digit is a bit (0 or 1).
  • Denary (decimal, base‑10) – used by humans.
  • Hexadecimal (base‑16) – convenient for representing binary groups; digits 0‑9 and A‑F.
  • Conversion methods:
    • Binary ↔ Decimal (repeated division / multiplication).
    • Binary ↔ Hexadecimal (group bits in fours).
  • Two’s‑complement for signed integers – invert bits and add 1.
  • Logical shifts (left/right) – multiply/divide by powers of two.

1.2 Text, sound and image representation

  • Text: ASCII (7‑bit) and Unicode (up to 32‑bit). One character = one byte (ASCII) or more (Unicode).
  • Sound: sampled at a given sample rate (e.g., 44 kHz) and stored with a bit depth (e.g., 16‑bit). Size ≈ sample rate × bit‑depth × duration.
  • Images:
    • Resolution – number of pixels (width × height).
    • Colour depth – bits per pixel (e.g., 24‑bit true colour = 16 777 216 colours).
    • Common formats: BMP (uncompressed), JPEG (lossy), PNG (lossless).

1.3 Data storage & compression

  • Units: bit, byte (8 bits), kilobyte (KB = 10³ B), megabyte (MB = 10⁶ B), gigabyte (GB = 10⁹ B). For RAM, binary prefixes (KiB = 2¹⁰ B) are also used.
  • Lossless compression – data can be restored exactly (e.g., ZIP, PNG).
  • Lossy compression – some information is discarded for smaller size (e.g., MP3, JPEG).

1.4 Data transmission & networking

  • Transmission media: copper cable, fibre‑optic, wireless (Wi‑Fi, Bluetooth).
  • Packets – units of data sent over a network; contain header (addressing) and payload.
  • Error‑detection methods: parity bit, checksum, CRC.
  • Encryption basics – symmetric (same key) vs asymmetric (public‑private key).

1.5 Core hardware

  • CPU – fetch‑decode‑execute cycle, registers, ALU, control unit.
  • Cache memory – speeds up access to frequently used data.
  • Multi‑core processors – parallel execution of threads.
  • Embedded systems – computers built into appliances, robots, IoT devices.

1.6 Software layers

  • Firmware – low‑level software stored in ROM/flash.
  • Operating System (OS) – manages resources, provides system calls.
  • Application software – programs written by users (e.g., word processors, games).
  • Interrupts – signals that temporarily suspend the CPU to handle urgent tasks.

1.7 Internet basics

  • URL structure – protocol, domain, path, query string.
  • HTTP/HTTPS – request/response protocol; HTTPS adds TLS encryption.
  • DNS – translates domain names to IP addresses.
  • Cookies – small pieces of data stored on the client side.

1.8 Cyber‑security

  • Common threats: malware, phishing, denial‑of‑service, man‑in‑the‑middle.
  • Counter‑measures: firewalls, antivirus, strong passwords, two‑factor authentication, regular updates.

1.9 Emerging technologies (AO1 – knowledge)

  • Artificial Intelligence – machine learning, neural networks.
  • Robotics – sensors, actuators, control algorithms.
  • Internet of Things (IoT) – networked everyday objects.
  • Cloud computing – on‑demand resources, SaaS, PaaS, IaaS.

2. Algorithms, Program Development and Logic (Syllabus Areas 7‑10)

2.1 Program development life‑cycle

  1. Analysis – understand the problem, define inputs & outputs.
  2. Design – decompose the solution, create structure diagrams, flowcharts.
  3. Coding – write pseudocode or a program using the correct syntax.
  4. Testing & debugging – validation (does the program meet the specification?) and verification (does it work correctly?).
  5. Documentation – comments, user guide, maintenance notes.

2.2 Decomposition and structure diagrams

Break a problem into smaller sub‑routines. Example – “Calculate a student’s final grade”.


MAIN
    INPUT marks for three tests
    CALL Average
    CALL DetermineGrade
    OUTPUT final grade
ENDMAIN

2.3 Flowchart symbols (exact syllabus symbols)

SymbolNamePurpose
ProcessArithmetic, assignment, input, output
DecisionBoolean test – two possible paths
Sub‑routineCall a separate routine
▶︎ / ◀︎ConnectorJoin or split flow lines
Start / EndProgram entry and termination

2.4 Pseudocode conventions (Cambridge style)

  • Keywords in UPPERCASE: IF … THEN … ELSE … ENDIF, FOR … TO … NEXT, WHILE … REPEAT … ENDWHILE.
  • Indentation – each new block indented one level (usually 4 spaces).
  • Comments start with // or # and are placed on a separate line.
  • Identifiers – start with a letter, may contain letters, digits or underscore, case‑insensitive.
  • Use for assignment (or = if the language requires it).

2.5 Trace tables

A trace table records the values of variables after each step of execution. Include columns for:

  • Step number
  • Variable values (all that change)
  • Output (if any)

Worked example – average of three numbers

Stepnum1num2num3sumaverage
112159
236
312

2.6 Validation and verification

  • Validation checks – ensure input data are within acceptable ranges (e.g., IF age < 0 OR age > 120 THEN ERROR).
  • Verification tests – use normal, boundary and extreme test data to prove the program works correctly.

2.7 Arrays (1‑D and 2‑D)

Arrays store a collection of values of the same type.


// 1‑D array of 5 integers
scores[5] ← {0,0,0,0,0}

// 2‑D array (3 rows × 2 columns)
matrix[3][2] ← {{1,2},{3,4},{5,6}}

Common operations: indexing, looping with FOR i ← 1 TO n, finding the sum or maximum.

2.8 File handling (basic syllabus requirements)


OPEN "data.txt" FOR READ AS f
WHILE NOT EOF(f) DO
    READ line FROM f
    // process line
ENDWHILE
CLOSE f

2.9 Databases and simple SQL (AO2 – application)

  • Table structure – rows (records) and columns (fields).
  • Key concepts: primary key, foreign key.
  • Typical queries:
    SELECT name, grade FROM students WHERE grade >= 70;
    INSERT INTO students (name, grade) VALUES ('Ali', 85);

2.10 Boolean‑gate circuits (AO1 – knowledge)

GateSymbolTruth table
AND AND gate
ABOUT
000
010
100
111
OR OR gate
ABOUT
000
011
101
111
NOT NOT gate
AOUT
01
10

3. Operators – arithmetic, relational and Boolean

3.1 Arithmetic operators

OperatorNamePseudocode exampleResult
+Additionc ← a + bSum of a and b
-Subtractionc ← a - bDifference of a and b
*Multiplicationc ← a * bProduct of a and b
/Division (real number)c ← a / bQuotient, may contain a fractional part
^Exponentiationc ← a ^ ba raised to the power b
MODModulus (remainder)c ← MOD(a, b)Remainder after a ÷ b
DIVInteger divisionc ← DIV(a, b)Whole‑number part of a ÷ b

3.2 Relational (logical) operators

OperatorMeaningPseudocode exampleResult
=Equal toa = bTRUE if a and b are the same
<>Not equal toa <> bTRUE if a and b differ
<Less thana < bTRUE if a is smaller than b
>Greater thana > bTRUE if a is larger than b
<=Less than or equal toa <= bTRUE if a ≤ b
>=Greater than or equal toa >= bTRUE if a ≥ b

Note: In many languages equality is written == and inequality !=, but the IGCSE exam requires = and <>.

3.3 Boolean operators

OperatorNameExpressionResult
ANDLogical ANDA AND BTRUE only if both A and B are TRUE
ORLogical ORA OR BTRUE if at least one of A or B is TRUE
NOTLogical NOTNOT ATRUE when A is FALSE, and FALSE when A is TRUE

3.4 Operator precedence (highest → lowest)

  1. Parentheses ( )
  2. Unary operators – NOT, unary minus -
  3. Exponentiation ^
  4. Multiplicative – *, /, MOD, DIV
  5. Additive – +, -
  6. Relational – =, <>, <, >, <=, >=
  7. Logical AND
  8. Logical OR

Use parentheses to make the intended order explicit.

3.5 Example evaluation (step‑by‑step)

result ← (a + b) ^ 2 DIV c AND (d > e)
  1. Parentheses: evaluate (a + b) and (d > e).
  2. Exponentiation: (a + b) ^ 2.
  3. Integer division: … DIV c (still a numeric value).
  4. Relational test: (d > e) yields TRUE or FALSE.
  5. Logical AND combines the numeric result (treated as TRUE if non‑zero) with the Boolean result of step 4.

4. Truth tables for Boolean operators

AND

ABA AND B
TRUETRUETRUE
TRUEFALSEFALSE
FALSETRUEFALSE
FALSEFALSEFALSE

OR

ABA OR B
TRUETRUETRUE
TRUEFALSETRUE
FALSETRUETRUE
FALSEFALSEFALSE

NOT

ANOT A
TRUEFALSE
FALSETRUE

5. Example programs (pseudocode)

5.1 Average of three numbers

num1 ← 12
num2 ← 15
num3 ← 9
sum   ← num1 + num2 + num3
average ← sum / 3
OUTPUT "Average = ", average

5.2 Eligibility test (relational + Boolean)

age      ← 17
hasPermit← TRUE
eligible ← (age >= 16) AND hasPermit
IF eligible THEN
    OUTPUT "You may drive."
ELSE
    OUTPUT "You are not eligible."
ENDIF

5.3 Exponentiation and integer division

base   ← 5
exp    ← 3
power  ← base ^ exp          // 5³ = 125
quot   ← DIV(125, 12)        // 10
remainder ← MOD(125, 12)     // 5
OUTPUT power, quot, remainder

5.4 Sum of an array (1‑D)

DECLARE scores[5] ← {8, 7, 9, 6, 10}
total ← 0
FOR i ← 1 TO 5 DO
    total ← total + scores[i]
ENDFOR
OUTPUT "Total =", total

5.5 Simple file read (list of names)

OPEN "names.txt" FOR READ AS f
WHILE NOT EOF(f) DO
    READ line FROM f
    OUTPUT line
ENDWHILE
CLOSE f

5.6 Database query (SQL style)

SELECT name, grade
FROM students
WHERE grade >= 70;

5.7 Boolean‑gate circuit example (AND followed by NOT)

Expression: NOT (A AND B) – this is a NAND gate.

ABA AND BNOT (A AND B)
0001
0101
1001
1110

6. Practice questions (with brief guidance)

  1. Precedence: Evaluate 5 + 3 * 2.
    Multiplication first → 3*2 = 6; then addition → 5+6 = 11.
  2. Write a Boolean expression that is TRUE only when n is between 10 and 20 inclusive.
    Answer: (n >= 10) AND (n <= 20).
  3. Given a ← 7 and b ← 3, evaluate MOD(a, b) = 1.
    7 MOD 3 = 1 → expression is TRUE.
  4. Translate: “A student passes if they score at least 40 in the exam and have attendance of at least 75 %.”
    Pseudocode: pass ← (examScore >= 40) AND (attendance >= 75).
  5. Using precedence, find the value of result ← NOT (x > 5) OR (y = 0 AND z <> 2) for x←6, y←0, z←2.
    Step‑1: (x > 5)TRUE; NOT TRUEFALSE.
    Step‑2: (y = 0)TRUE.
    Step‑3: (z <> 2)FALSE.
    Step‑4: TRUE AND FALSEFALSE.
    Step‑5: FALSE OR FALSEFALSE. Hence result = FALSE.
  6. Calculate integer division and remainder of 47 ÷ 6.
    quot ← DIV(47, 6) // 7
    rem ← MOD(47, 6) // 5
    Write both statements in pseudocode as shown.

7. Summary of key points

  • Computer systems: binary, hexadecimal, data representation, hardware, software, networking and security fundamentals.
  • Algorithm design: life‑cycle, decomposition, flowcharts, trace tables, validation & verification.
  • Operators: arithmetic (+, -, *, /, ^, MOD, DIV), relational (=, <>, <, >, <=, >=), Boolean (AND, OR, NOT).
  • Precedence determines the order of evaluation; parentheses override it.
  • Truth tables are essential for checking Boolean logic and for designing gate circuits.
  • Arrays, file handling and databases extend the basic programming toolkit and are required for many exam questions.
  • Always follow the Cambridge pseudocode conventions – uppercase keywords, clear indentation and comments.

Create an account or Login to take a Quiz

43 views
0 improvement suggestions

Log in to suggest improvements to this note.