Kramizo
Log inSign up free
HomeCIE IGCSE Computer ScienceProgramming concepts: input/output, assignment and arithmetic, comparison and logical operators
CIE · IGCSE · Computer Science · Revision Notes

Programming concepts: input/output, assignment and arithmetic, comparison and logical operators

2,049 words · Last updated May 2026

Ready to practise? Test yourself on Programming concepts: input/output, assignment and arithmetic, comparison and logical operators with instantly-marked questions.
Practice now →

What you'll learn

This guide covers the fundamental programming operations you must know for CIE IGCSE Computer Science. You'll learn how data flows into and out of programs, how variables store and manipulate values, and how programs make decisions using comparison and logical operators. These concepts form the foundation of every program you'll write or analyse in your exam.

Key terms and definitions

Input — the process of receiving data into a program from an external source such as keyboard, file or sensor

Output — the process of sending data from a program to an external destination such as screen, file or speaker

Assignment — the process of storing a value in a variable using the assignment operator (typically = or )

Variable — a named storage location in memory that holds a value which can change during program execution

Operator precedence — the order in which operators are evaluated in an expression, with some operations performed before others

Comparison operator — an operator that compares two values and returns a Boolean result (TRUE or FALSE)

Logical operator — an operator (AND, OR, NOT) that combines or inverts Boolean values to produce a Boolean result

Arithmetic operator — an operator that performs mathematical calculations on numeric values (+, -, *, /, MOD, DIV)

Core concepts

Input and output operations

Programs need to interact with users and other systems. Input operations bring data into a program, while output operations send results out.

Standard input methods:

  • INPUT or READ statements accept data typed by the user
  • File reading operations retrieve stored data
  • Sensor readings capture real-world measurements
  • Network communications receive data from other systems

Standard output methods:

  • OUTPUT, PRINT or DISPLAY statements show results to the user
  • File writing operations save data permanently
  • Screen displays present visual information
  • Network communications send data to other systems

Pseudocode syntax (CIE specification):

INPUT UserAge
OUTPUT "You are ", UserAge, " years old"

Common programming language equivalents:

  • Python: input() and print()
  • Visual Basic: Console.ReadLine() and Console.WriteLine()

Input always returns string/text data by default. You must convert numeric input before performing calculations.

Variable assignment

Assignment stores a value in a variable. The variable name appears on the left, the value or expression on the right.

Assignment operator:

In pseudocode: or =

Total ← 0
Count ← Count + 1
Name ← "Sarah"

Key principles:

  • Assignment is not equality. X ← 5 means "store 5 in X", not "X equals 5"
  • The right side is evaluated first, then stored in the left side variable
  • Variables must be declared or initialised before use in some languages
  • Variable names should be meaningful (e.g., StudentAge not X)

Data type considerations:

Different data types require appropriate values:

  • Integer variables: whole numbers (e.g., Age ← 16)
  • Real/Float variables: decimal numbers (e.g., Price ← 12.99)
  • String variables: text in quotes (e.g., Name ← "John")
  • Boolean variables: TRUE or FALSE (e.g., IsValid ← TRUE)

Arithmetic operators and expressions

Arithmetic operators perform mathematical calculations. Understanding operator precedence prevents calculation errors.

Standard arithmetic operators:

Operator Meaning Example Result
+ Addition 7 + 3 10
- Subtraction 7 - 3 4
* Multiplication 7 * 3 21
/ Division (real) 7 / 3 2.333...
DIV Integer division 7 DIV 3 2
MOD Modulus (remainder) 7 MOD 3 1
^ Exponentiation 2 ^ 3 8

Operator precedence (BIDMAS/BODMAS):

  1. Brackets
  2. Indices/Exponents (^)
  3. Division and Multiplication (left to right)
  4. MOD and DIV (left to right)
  5. Addition and Subtraction (left to right)

Example: 5 + 3 * 2 evaluates to 11 (not 16) because multiplication happens before addition.

Practical applications:

  • DIV extracts the quotient: 17 DIV 5 = 3
  • MOD extracts the remainder: 17 MOD 5 = 2
  • MOD 2 tests if a number is even: X MOD 2 = 0 means X is even
  • MOD 10 extracts the last digit: 2847 MOD 10 = 7
  • DIV 10 removes the last digit: 2847 DIV 10 = 284

Comparison operators

Comparison operators evaluate relationships between values and return Boolean results (TRUE or FALSE).

Standard comparison operators:

Operator Meaning Example Result when X = 5
= Equal to X = 5 TRUE
<> or ≠ Not equal to X <> 3 TRUE
> Greater than X > 4 TRUE
< Less than X < 4 FALSE
>= or ≥ Greater than or equal X >= 5 TRUE
<= or ≤ Less than or equal X <= 4 FALSE

Common uses:

  • Validating user input: Age >= 13
  • Checking password matches: InputPassword = StoredPassword
  • Testing loop conditions: Counter < 10
  • Range checking: Mark >= 0 AND Mark <= 100

String comparisons:

Strings compare alphabetically (lexicographically):

  • "Apple" < "Banana" returns TRUE
  • "cat" > "Cat" returns TRUE (lowercase letters have higher ASCII values)

Logical operators

Logical operators combine multiple Boolean expressions or invert Boolean values.

Three essential logical operators:

AND operator:

  • Returns TRUE only if both conditions are TRUE
  • Used for conditions that must both be satisfied
  • Truth table:
A B A AND B
TRUE TRUE TRUE
TRUE FALSE FALSE
FALSE TRUE FALSE
FALSE FALSE FALSE

Example: Age >= 18 AND HasLicence = TRUE

OR operator:

  • Returns TRUE if at least one condition is TRUE
  • Used for alternative conditions
  • Truth table:
A B A OR B
TRUE TRUE TRUE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE

Example: Grade = "A" OR Grade = "B"

NOT operator:

  • Inverts a Boolean value
  • TRUE becomes FALSE, FALSE becomes TRUE
  • Truth table:
A NOT A
TRUE FALSE
FALSE TRUE

Example: NOT(IsComplete)

Complex conditions:

Logical operators can be combined with brackets to create sophisticated conditions:

IF (Age >= 18 AND CitizenStatus = "UK") OR HasWorkPermit = TRUE THEN
    OUTPUT "Eligible for employment"
ENDIF

Evaluation order:

  1. Brackets (innermost first)
  2. NOT
  3. AND
  4. OR

Example: TRUE OR FALSE AND FALSE evaluates to TRUE because AND is evaluated first, giving TRUE OR FALSE = TRUE.

Type conversion and input handling

Input operations typically return string data. Numerical calculations require type conversion.

Type conversion functions:

  • String to integer: convert user input for whole number calculations
  • String to real: convert user input for decimal calculations
  • Integer/real to string: prepare numbers for output or concatenation

Pseudocode example:

OUTPUT "Enter your age: "
INPUT AgeString
Age ← INT(AgeString)
NextYear ← Age + 1
OUTPUT "Next year you will be ", NextYear

Without conversion:

If AgeString = "16" and you write AgeString + 1, different languages handle this differently. Some produce an error, others concatenate to give "161" rather than calculating 17.

Best practice:

  • Always convert numeric input immediately after reading
  • Validate input before conversion to avoid errors
  • Use meaningful variable names to indicate data types

Worked examples

Example 1: Calculating parking charges

A car park charges £2.50 per hour. Write pseudocode to input the number of hours parked and calculate the total charge.

Solution:

DECLARE Hours : INTEGER
DECLARE Total : REAL

OUTPUT "Enter number of hours parked: "
INPUT Hours
Total ← Hours * 2.50
OUTPUT "Total charge: £", Total

Mark scheme points:

  • Input statement with appropriate prompt (1 mark)
  • Correct conversion to integer (1 mark)
  • Correct calculation using multiplication (1 mark)
  • Appropriate output statement (1 mark)

Example 2: Validating age range

Write a Boolean expression that returns TRUE if a person's age is between 13 and 18 inclusive.

Solution:

Age >= 13 AND Age <= 18

Alternative correct answer:

NOT(Age < 13) AND NOT(Age > 18)

Mark scheme points:

  • Correct lower bound check (1 mark)
  • Correct upper bound check (1 mark)
  • Correct use of AND operator (1 mark)

Example 3: MOD and DIV operations

A shop needs to give change using the minimum number of notes and coins. Write pseudocode to calculate how many £5 notes and how many £1 coins are needed for a given amount.

Solution:

DECLARE Amount : INTEGER
DECLARE FiveNotes : INTEGER
DECLARE OneCoins : INTEGER

OUTPUT "Enter amount in pounds: "
INPUT Amount
FiveNotes ← Amount DIV 5
OneCoins ← Amount MOD 5
OUTPUT "£5 notes: ", FiveNotes
OUTPUT "£1 coins: ", OneCoins

Mark scheme points:

  • Correct use of DIV to find number of £5 notes (2 marks)
  • Correct use of MOD to find remaining £1 coins (2 marks)
  • Appropriate input and output statements (1 mark)

Example walkthrough with Amount = 18:

  • FiveNotes ← 18 DIV 5 gives 3
  • OneCoins ← 18 MOD 5 gives 3
  • Output: 3 five-pound notes and 3 one-pound coins

Common mistakes and how to avoid them

  • Confusing assignment with comparison: Writing X = 5 in a condition when you mean X ← 5 for assignment. In pseudocode, assigns while = compares. Always use the correct operator for the context.

  • Ignoring operator precedence: Calculating 5 + 3 * 2 as 16 instead of 11. Remember BIDMAS: multiplication before addition. Use brackets (5 + 3) * 2 when you need to override precedence.

  • Misusing logical operators: Writing X = 5 OR 6 instead of X = 5 OR X = 6. Each side of a logical operator must be a complete Boolean expression.

  • Forgetting MOD vs DIV: Using MOD when you need DIV or vice versa. MOD gives the remainder (7 MOD 3 = 1), DIV gives the quotient (7 DIV 3 = 2). Check which you actually need.

  • String concatenation instead of addition: Performing "5" + "3" giving "53" instead of 8. Always convert string input to numeric types before arithmetic: INT("5") + INT("3") = 8.

  • Off-by-one errors in ranges: Writing Age > 18 when you mean "18 and over" (should be Age >= 18). Check whether boundaries are inclusive (>=, <=) or exclusive (>, <).

Exam technique for Programming concepts: input/output, assignment and arithmetic, comparison and logical operators

  • Trace tables and dry runs: When asked to evaluate expressions or trace code, write down intermediate values at each step. Show 7 * 3 = 21, then 5 + 21 = 26 rather than jumping to the answer. This earns method marks even if the final answer is wrong.

  • Command words matter: "State" requires a brief answer (e.g., "TRUE"). "Calculate" requires showing working. "Write" pseudocode needs correct syntax and structure. "Explain" requires reasons, not just statements.

  • Pseudocode precision: Use CIE pseudocode conventions exactly: INPUT, OUTPUT, for assignment, capital letters for keywords. Examiners mark to the specification, so non-standard syntax may lose marks even if the logic is correct.

  • Check your brackets: Complex Boolean expressions need careful bracketing. Write (A AND B) OR C not A AND B OR C if you want to control evaluation order. Show brackets explicitly rather than relying on operator precedence.

Quick revision summary

Programs use INPUT to receive data and OUTPUT to display results. Assignment (←) stores values in variables. Arithmetic operators (+, -, *, /, DIV, MOD) perform calculations following BIDMAS precedence. Comparison operators (=, <>, >, <, >=, <=) compare values and return Boolean results. Logical operators (AND, OR, NOT) combine conditions. MOD gives remainders, DIV gives integer quotients. AND requires both conditions true, OR requires at least one true, NOT inverts a Boolean value. Always convert string input to numbers before arithmetic operations.

Free for IGCSE students

Lock in Programming concepts: input/output, assignment and arithmetic, comparison and logical operators with real exam questions.

Free instantly-marked CIE IGCSE Computer Science practice — 45 questions a day, no card required.

Try a question →See practice bank