Assignment Statements & Arithmetic

Master the backbone of algorithmic logic for CSEC IT

1

The Building Blocks of Logic

What is an Assignment Statement?
Think of it as giving a labeled box (a variable) a specific value. In programming, we don’t just “do math”; we store the results of that math into memory so we can use them later.

The Role of Arithmetic:
Algorithms solve problems by calculating. Whether you are calculating a student’s average score or the total cost of items at a Caribbean market, arithmetic operations are the tools you use to process data.

Working Together:
An assignment statement is usually the final step of an arithmetic process.

1. Calculate: price + tax
2. Assign: total result
2

Variables and Constants

Variables

A variable is a named location in memory used to store data that can change during program execution.

  • Example: Counter (starts at 0, goes up to 10), Grade (changes for each student).

Constants

A constant is a named location in memory used to store data that remains the same throughout the program.

  • Example: VAT_Rate (always 0.15 or 15%), PI (3.14).
Visual Memory

How values are stored in computer memory

Age
16
VAT
0.15
Score
85
3

Understanding Assignment

An assignment statement gives a value to a variable. It uses the assignment operator ( in CSEC Pseudocode).

The Rule of the Arrow (←)

Important: The arrow points from the value/expression on the right to the variable on the left.

total price + tax

The computer calculates the sum of price and tax first, then stores the result into total.

Assignment vs. Equality

Do not confuse the assignment arrow () with mathematical equality (=).

  • Math: A = B (A is the same as B)
  • Programming: A ← B (Copy the value of B into A. B stays unchanged.)
4

Arithmetic Operators

These are the symbols used to perform mathematical calculations in algorithms.

Operation Symbol Pseudocode Example Result (if A=10, B=3)
Addition + Ans ← A + B 13
Subtraction Ans ← A - B 7
Multiplication × Ans ← A × B 30
Division ÷ Ans ← A ÷ B 3.33
Modulus MOD Ans ← A MOD B 1

Deep Dive: The Modulus (MOD)

The MOD operator gives the remainder after a division. It is very useful in programming logic.

  • Real Life: You have 17 candies. You put them in bags of 5. How many are left over?
  • Calculation: 17 ÷ 5 = 3 bags. 17 MOD 5 = 2 candies left.
  • Programming Use: Checking if a number is Even or Odd. If Num MOD 2 = 0, it is Even.
5

Order of Operations (BODMAS)

Just like in Math class, programming follows a specific order. If you ignore this, your algorithm will produce wrong results.

BODMAS / PEMDAS Priority:

  1. Brackets ( )
  2. Orders (Powers/Roots – rarely used in basic CSEC but good to know)
  3. Division and Multiplication (×, ÷, MOD) — Done left to right
  4. Addition and Subtraction (+, -) — Done left to right
Example: Ans 2 + 3 × 4

Wrong: 5 × 4 = 20
Correct: 3 × 4 = 12, then 2 + 12 = 14

Using Brackets for Clarity

Always use brackets ( ) to force the order you want.

Average (Score1 + Score2) ÷ 2

Without brackets, the computer would divide Score2 by 2 first, then add Score1, giving a completely wrong average!

6

Algorithms in Action

1. Calculating an Average

Calculating the average of three test scores for a student report.

BEGIN
  INPUT Math, English, Science
  Sum Math + English + Science
  Average Sum ÷ 3
  OUTPUT Average
END

2. Flowchart Representation

Visualizing the logic for a simple calculation: Result = (A + B) * 2.

START
INPUT A, B
Sum ← A + B
Result ← Sum × 2
OUTPUT Result
STOP
7

Common Pitfalls

  • Confusing = with ←: Using the math symbol instead of the assignment arrow in pseudocode.
  • Ignoring BODMAS: Writing Num1 + Num2 / 2 when calculating an average. (Must use brackets).
  • Misusing MOD: Thinking 10 MOD 3 is 3. It is actually 1 (the remainder).
  • Overwriting Variables: If you calculate Average but store it in Sum, you lose the original sum data!
8

Interactive Challenge

Predict the Output

Assume: X = 5, Y = 3. What is the result of this operation?

Ans (X + 2) × Y

Solve: (5 + 2) × 3 = ?

Fill in the Blank

Complete the assignment statement to find the remainder when 20 is divided by 6.

Result ← 20 6
9

CSEC Exam Focus

Understanding assignment and arithmetic is critical for Paper 1 (Multiple Choice) and Paper 2 (Problem Solving/Programming).

Trace Tables

You will often be given a code segment and asked to track the value of variables line-by-line.

1. A ← 10
2. B ← 4
3. A ← A + B
4. B ← A – 2

Tip: Be careful! Line 3 changes the value of A, so Line 4 uses the new value of A (14), not the old one.

Algorithm Writing

You may be asked to write an algorithm that involves calculating values (e.g., Calculate Area of a room). You must use the correct assignment syntax.

10

Exam Practice Questions

Test your knowledge with these CSEC-style questions. Click to reveal answers.

Question 1: Multiple Choice

Which of the following represents the assignment operator in pseudocode?

  • =
  • :
  • ==
Answer: (b) ←
Question 2: Multiple Choice

What is the value of Y after execution?

X ← 5
Y ← X × 2
X ← 10
Answer: 10.
(Explanation: Y is calculated as 5 × 2 = 10. Changing X afterwards does not change Y).
Question 3: Calculation

Evaluate: 15 MOD 4

Answer: 3.
(Explanation: 15 ÷ 4 = 3 with a remainder of 3).
Question 4: Calculation

Evaluate: 2 + 3 × 6 - 4

Answer: 16.
(Explanation: 3 × 6 = 18. 2 + 18 = 20. 20 – 4 = 16).
Question 5: Short Answer

Write an assignment statement to calculate the Area of a rectangle (Length and Width are given).

Answer: Area ← Length × Width
Question 6: Algorithm

Write pseudocode to accept a number, double it, and add 5. Output the final result.

Answer:
BEGIN
  INPUT Num
  Result ← (Num × 2) + 5
  OUTPUT Result
END
11

Real World Scenario: The School Tuck Shop

Let’s apply what we’ve learned to a familiar situation in the Caribbean. Imagine you are writing a program for the school cashier to calculate bills.

The Problem

A student buys 3 Patties at $150 each and 1 Juice at $100. The school adds a 10% Service Charge (tax) to every bill. Calculate the Total Cost.

The Algorithm

BEGIN
  // Constants
  PRICE_PATTIE 150
  PRICE_JUICE 100
  TAX_RATE 0.10

  // Inputs
  INPUT NumPatties
  INPUT NumJuices

  // Calculations
  Subtotal (NumPatties × PRICE_PATTIE) + (NumJuices × PRICE_JUICE)
  TaxAmount Subtotal × TAX_RATE
  TotalCost Subtotal + TaxAmount

  OUTPUT TotalCost
END

Walkthrough: Notice how we used brackets to group the pattie costs and juice costs before adding them together? This ensures the program doesn’t make a math mistake!

12

Code Detective: Find the Bug

Even experienced programmers make mistakes. Can you find the logic error in the code below?

The Goal

Calculate the average of 3 numbers: 10, 20, and 30.

Num1 ← 10
Num2 ← 20
Num3 ← 30
Average ← Num1 + Num2 + Num3 / 3

What is the mistake?

13

Quick Glossary

Assignment

Copying a value into a variable (using ←).

Expression

A combination of variables, operators, and values that results in a single value (e.g., A + 5).

Integer Division

Division that discards the remainder (e.g., 7 ÷ 2 = 3).

Modulus (MOD)

The operator that finds the remainder of a division.

14

Summary

  • ✅ Assignment statements () store results into variables. The arrow points Left.
  • ✅ Variables change; Constants stay the same.
  • ✅ Arithmetic includes Add, Subtract, Multiply, Divide, and MOD.
  • ✅ Always follow BODMAS. Use brackets to control the order of calculation.
  • ✅ In exams, check Trace Tables carefully—once a variable is updated, the old value is gone.

Video Tutorial

Watch this quick recap on Arithmetic and Assignment Logic.

Ready for the Next Topic?

Now that you can store and calculate data, the next step is making decisions.

Go to: Selection (IF/THEN)
Scroll to Top