Skip to main content

📘 CIE IGCSE Computer Science

💻 Programming Concepts – Detailed Notes

1️⃣ Variables and Constants

🔹 Variable​

A variable is a named storage location in memory whose value can change during program execution.

✅ Declaration​

You must:

  • Choose a meaningful identifier
  • Specify the data type
  • Assign a value (optional at declaration in some languages)

Example (pseudocode):

DECLARE age : INTEGER
age ← 16

🧠 Exam Tip​

  • Always use meaningful names:
    • ❌ x
    • ✅ studentAge
  • Variables must be declared before use.

🔹 Constant​

A constant is a named value that does NOT change during program execution.

Example:

DECLARE PI : REAL
PI ← 3.142

Or:

CONSTANT MAX_MARK ← 100

🧠 Exam Tip​

  • Use constants for fixed values (tax rate, maximum size, etc.)
  • Makes program easier to maintain.

2️⃣ Basic Data Types

You must know these:

Data TypeDescriptionExample
INTEGERWhole numbers5, -2
REALDecimal numbers3.14, -1.5
CHARSingle character'A'
STRINGMultiple characters"Hello"
BOOLEANTrue or FalseTRUE

🔹 Examples​

DECLARE score : INTEGER
DECLARE temperature : REAL
DECLARE initial : CHAR
DECLARE name : STRING
DECLARE isPassed : BOOLEAN

🧠 Common Exam Mistakes​

  • Using STRING instead of CHAR
  • Storing decimals in INTEGER
  • Confusing BOOLEAN with STRING

3️⃣ Input and Output

🔹 Input​

Used to get data from the user.

INPUT name
INPUT age

🔹 Output​

Used to display data.

OUTPUT "Welcome"
OUTPUT name

🧠 Exam Tip​

  • Always prompt clearly:

OUTPUT "Enter your age:"
INPUT age

4️⃣ Control Structures

These are the three fundamental programming constructs.

🔹 (a) Sequence

Instructions executed in order.

INPUT number
square ← number * number
OUTPUT square

Execution flows top → bottom.

🔹 (b) Selection

Used to make decisions.

1️⃣ IF Statement​

IF mark >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF

2️⃣ CASE Statement​

Used when there are many possible values.

CASE grade OF
"A": OUTPUT "Excellent"
"B": OUTPUT "Good"
"C": OUTPUT "Average"
OTHERWISE OUTPUT "Invalid"
ENDCASE

🧠 Use CASE when:​

  • Comparing ONE variable to MANY values.

🔹 (c) Iteration (Loops)

Used to repeat instructions.

1️⃣ Count-Controlled Loop​

Repeats a fixed number of times.

FOR i ← 1 TO 5
OUTPUT i
NEXT i

2️⃣ Pre-condition Loop​

Condition checked BEFORE loop runs.

WHILE number > 0 DO
INPUT number
ENDWHILE

If condition is false initially → loop never runs.

3️⃣ Post-condition Loop​

Condition checked AFTER loop runs.

REPEAT
INPUT number
UNTIL number = 0

Runs at least once.

🧠 Exam Tip​

Know the difference between:

  • WHILE (pre-condition)
  • REPEAT UNTIL (post-condition)

🔹 (d) Totalling and Counting

Very common in exams.

Counting Example​

count ← 0
FOR i ← 1 TO 5
INPUT number
IF number > 10 THEN
count ← count + 1
ENDIF
NEXT i

Totalling Example​

total ← 0
FOR i ← 1 TO 5
INPUT number
total ← total + number
NEXT i

🧠 Important Rule​

  • Initialize counters and totals to 0
  • Update inside loop

🔹 (e) String Handling

Know these functions:

FunctionMeaning
LENGTH(string)Returns length
SUBSTRING(string, start, length)Extracts part
UPPER(string)Converts to uppercase
LOWER(string)Converts to lowercase

Example​

name ← "Austin"

OUTPUT LENGTH(name) // 6
OUTPUT SUBSTRING(name,1,3) // Aus
OUTPUT UPPER(name) // AUSTIN

⚠️ The first character position may be 0 or 1 depending on language.

🔹 (f) Operators

Arithmetic Operators​

OperatorMeaning
+Addition
-Subtraction
*Multiply
/Divide
^Power
MODRemainder
DIVInteger division

Example:

10 DIV 3 = 3
10 MOD 3 = 1

Relational Operators​

OperatorMeaning
=Equal
<>Not equal
<Less than
>Greater than
<=Less or equal
>=Greater or equal

Logical Operators​

OperatorMeaning
ANDBoth true
ORAt least one true
NOTOpposite

Example:

IF age >= 16 AND citizen = TRUE THEN

5️⃣ Nested Statements

A statement inside another statement.

Example (nested IF):

IF age >= 16 THEN
IF hasID = TRUE THEN
OUTPUT "Allowed"
ENDIF
ENDIF

Nested loop example:

FOR i ← 1 TO 3
FOR j ← 1 TO 2
OUTPUT i, j
NEXT j
NEXT i

⚠️ Maximum 3 levels in exam.

6️⃣ Procedures and Functions

🔹 Procedure​

A subprogram that performs a task.
Does NOT return a value.

🔹 Function​

Returns a value.

🔹 Parameters​

Values passed into procedures/functions.

Up to 3 parameters in exam.

🔹 Local vs Global Variables​

TypeMeaning
GlobalAccessible everywhere
LocalOnly inside procedure/function

Example:

7️⃣ Library Routines

Built-in functions provided by language.

You must know:

  • MOD
  • DIV
  • ROUND
  • RANDOM

Example:

number ← RANDOM(1,10)
rounded ← ROUND(3.6)

8️⃣ Writing Maintainable Programs

Very important for high marks.

✅ Meaningful Identifiers​

✅ Commenting​

Use comments to explain logic:

Comment:

  • Complex logic
  • Procedures
  • Important formulas

Do NOT:

  • Comment obvious lines unnecessarily

✅ Use Procedures and Functions​

Break large programs into smaller parts.

Benefits:

  • Easier debugging
  • Easier testing
  • Easier modification
  • Improves readability

⭐ Common Exam Question Types

  1. Trace the code.
  2. Complete missing code.
  3. Write an IF or loop.
  4. Identify data type.
  5. Explain difference between loop types.
  6. Identify errors.
  7. Write a procedure/function.

🚨 Very Common Mistakes

❌ Forgetting to initialise total
❌ Using = instead of ←
❌ Infinite loops
❌ Wrong loop type
❌ Not using meaningful identifiers
❌ Mixing up MOD and DIV

🎯 Final Exam Advice

✔ Read question carefully
✔ Underline key words (count, total, repeat until, etc.)
✔ Use indentation properly
✔ Check loop conditions
✔ Check variable names are consistent