Category Scores
Use DIM to create an array that tracks scores per category, then display a breakdown.
The quiz tracks a total score, but the player can’t see which categories they’re strong or weak in. An array — one slot per category — fixes that.
DIM — Creating an Array
10 DIM s(4)
20 LET s(1)=3
30 LET s(2)=1
40 LET s(3)=2
50 LET s(4)=0
60 FOR i=1 TO 4
70 PRINT "Category ";i;": ";s(i)
80 NEXT i
90 PRINT
100 LET t=s(1)+s(2)+s(3)+s(4)
110 PRINT "Total: ";t
DIM s(4) creates four numbered slots: s(1), s(2), s(3), s(4). Each starts at zero. You can read and write any slot by its number — and crucially, you can use a variable as the number.
Scoring by Category
When the player answers correctly, the category index p tells you which slot to update:
LET s(p) = s(p) + 1
If the question was Science (p = 1), this increments s(1). If Geography (p = 3), it increments s(3). One line handles all four categories because the index is a variable, not a hardcoded number.
The Category Breakdown
176 REM === Category breakdown ===
178 PRINT AT 8,6; INK 6;"Science: ";s(1)
180 PRINT AT 9,6; INK 3;"History: ";s(2)
182 PRINT AT 10,6; INK 4;"Geography: ";s(3)
184 PRINT AT 11,6; INK 5;"Entertainment: ";s(4)

Each category is printed with its colour and score. The player sees at a glance where they’re strong (high numbers) and where they need to study (zeros).
Arrays vs Variables
You could use four separate variables: s1, s2, s3, s4. But then you can’t write LET s(p) = s(p) + 1 — you’d need four IF statements to decide which variable to increment. Arrays turn the category number into direct access. That’s their power.
Rules
- DIM before use — declare the size before storing anything
- Starts at 1 —
DIM s(4)creates slots 1 to 4 (not 0 to 3) - All zeros — every slot starts at 0, no need to initialise
- Fixed size — you can’t make an array bigger after DIM
Try This
Best category. After the quiz, find which category scored highest. Start with LET h = 1, then loop: IF s(i) > s(h) THEN LET h = i. Print the winning category name.
Bar chart. For each category, print a row of coloured blocks: FOR j = 1 TO s(i): PRINT PAPER ci; " ";: NEXT j. The bars show the scores visually.
What You’ve Learnt
- DIM — creates an array:
DIM s(4)makes four numbered slots - Array indexing —
s(p)uses a variable to pick the right slot - One line for all categories —
LET s(p) = s(p) + 1handles any category - Category breakdown — print each slot with its matching colour and label