Score Breakdown
A second array tracks the score per category, so the end screen can break it down subject by subject — and a rating turns the total into a verdict.
A single total — 6 out of 8 — hides where you did well. A breakdown tells you: strong on
Space, weak on History. That needs a score per category, which is exactly what a second array is
for. Then a rating turns the total into a verdict, the IF-ladder you have used since Lucky
Number.
5 DIM k(8): DIM s(4)
10 BORDER 0: PAPER 0: INK 7: CLS
50 RESTORE: FOR i = 1 TO 8: READ k(i): NEXT i
60 RESTORE 600
70 FOR i = 1 TO 4: LET s(i) = 0: NEXT i
80 LET score = 0: LET n = 0
90 FOR c = 1 TO 4
100 READ t$,ink
110 FOR q = 1 TO 2
120 LET n = n + 1
130 CLS
140 PAPER ink: INK 7
150 FOR i = 0 TO 31: PRINT " ";: NEXT i
160 PRINT AT 0,1;t$
170 PRINT AT 0,26;score;"/8"
180 PAPER 7: INK 0
190 READ q$,a$,b$,c$,d$
200 PRINT AT 2,0;"Question ";n;" of 8"
210 PRINT AT 4,0;q$
220 PRINT AT 7,2;"1. ";a$
230 PRINT AT 8,2;"2. ";b$
240 PRINT AT 9,2;"3. ";c$
250 PRINT AT 10,2;"4. ";d$
260 PRINT AT 12,0;: INPUT "Answer (1-4): ";g
270 IF g = k(n) THEN PRINT AT 14,0;"Correct!": LET score = score + 1: LET s(c) = s(c) + 1: BEEP 0.2,12
280 IF g <> k(n) THEN PRINT AT 14,0;"The answer was ";k(n): BEEP 0.3,-5
290 PRINT AT 0,26;score;"/8"
300 PAUSE 80
310 NEXT q
340 NEXT c
350 CLS
360 PRINT AT 3,9;"Quiz complete!"
370 PRINT AT 5,6;"You scored ";score;" out of 8"
380 PRINT AT 8,4;"Animals: ";s(1);" / 2"
390 PRINT AT 9,4;"Space: ";s(2);" / 2"
400 PRINT AT 10,4;"History: ";s(3);" / 2"
410 PRINT AT 11,4;"Geography: ";s(4);" / 2"
420 IF score = 8 THEN INK 4: PRINT AT 14,10;"Quiz Master!": GO TO 460
430 IF score >= 6 THEN INK 5: PRINT AT 14,12;"Expert": GO TO 460
440 IF score >= 4 THEN INK 6: PRINT AT 14,11;"Not bad": GO TO 460
450 INK 2: PRINT AT 14,9;"Keep trying"
460 INK 0
550 DATA 1,2,3,4,3,2,3,2
600 DATA "Animals",4
610 DATA "How many legs does a spider have?","Eight","Six","Ten","Twelve"
620 DATA "What is the fastest land animal?","Lion","Cheetah","Horse","Wolf"
630 DATA "Space",5
640 DATA "Which planet is closest to the Sun?","Venus","Earth","Mercury","Mars"
650 DATA "How many planets orbit the Sun?","Seven","Nine","Ten","Eight"
660 DATA "History",2
670 DATA "In what year was the Moon landing?","1959","1965","1969","1972"
680 DATA "Which country built the pyramids?","Greece","Egypt","Rome","China"
690 DATA "Geography",6
700 DATA "What is the largest ocean?","Atlantic","Indian","Pacific","Arctic"
710 DATA "What is the capital of France?","London","Paris","Rome","Berlin"
An array indexed by category
DIM s(4) (line 5) makes a second array — one box per category. When an answer is right, line
270 adds to both score (the total) and s(c) (that category's tally), using the category
loop variable c as the index. So s(2) holds your Space score, s(3) your History score, and
so on. This is the array doing what arrays are best at: keeping a set of related counters you
address by number, instead of four separate variables you'd have to choose between with IFs.
The end screen (lines 380–410) just reads them back, one line per subject.
A rating for the whole
After the breakdown, lines 420–450 rate the total with the familiar ladder: 8 is "Quiz Master!", 6+ "Expert", 4+ "Not bad", below that "Keep trying", each in its own colour. The score stops being a bare number and becomes an identity — the thing the player replays to improve. Two arrays, working together: one keys the answers, one tallies the result.
Next: a title screen and replay — the finished game.