Skip to content
Game 6 Unit 2 of 8 1 hr learning time

Questions from DATA

Store multiple questions in DATA statements and loop through them with READ.

25% of Quiz Master

One question isn’t a quiz. You need a list of questions and a way to step through them automatically. DATA and READ handle both — and you already know them from Word Scramble.

Multiple Values in One READ

  10 LET sc=0
  20 FOR n=1 TO 4
  30 READ q$,a$,b$,c$,d$,r$
  40 PRINT "Q";n;": ";q$
  50 PRINT "  A: ";a$
  60 PRINT "  B: ";b$
  70 PRINT "  C: ";c$
  80 PRINT "  D: ";d$
  90 INPUT "Answer? ";k$
 100 IF k$=r$ THEN PRINT "Correct!": LET sc=sc+1: GO TO 120
 110 PRINT "Wrong! It was ";r$
 120 PRINT
 130 NEXT n
 140 PRINT "Score: ";sc;" out of 4"
 500 DATA "Closest planet to the Sun?","Mercury","Venus","Earth","Mars","a"
 510 DATA "Who built the pyramids?","Romans","Egyptians","Vikings","Greeks","b"
 520 DATA "Capital of France?","London","Berlin","Madrid","Paris","d"
 530 DATA "Instrument with 88 keys?","Guitar","Drums","Violin","Piano","d"

Each DATA line holds six values: the question, four options, and the correct answer letter. A single READ q$, a$, b$, c$, d$, r$ pulls all six into variables at once. The types must match — strings into string variables, in the right order.

Four Rounds

   5 BORDER 0: PAPER 0: INK 7: CLS
  10 FOR i=0 TO 31
  12 PRINT AT 0,i; PAPER 2;" "
  14 NEXT i
  16 LET sc=0
  20 FOR n=1 TO 4
  22 READ q$,a$,b$,c$,d$,r$
  24 CLS
  26 FOR i=0 TO 31
  28 PRINT AT 0,i; PAPER 2;" "
  30 NEXT i
  32 PRINT AT 0,1; PAPER 2; INK 7;"Q";n;" of 4"
  34 PRINT AT 0,22; PAPER 2; INK 6;"Score: ";sc
  36 PRINT AT 4,4; INK 7;q$
  38 PRINT AT 8,6; INK 7;"A: ";a$
  40 PRINT AT 10,6; INK 7;"B: ";b$
  42 PRINT AT 12,6; INK 7;"C: ";c$
  44 PRINT AT 14,6; INK 7;"D: ";d$
  46 PRINT AT 18,4;
  48 INPUT "Answer? ";k$
  50 IF k$=r$ THEN PRINT AT 18,4; INK 4; BRIGHT 1;"Correct!": LET sc=sc+1: GO TO 60
  52 PRINT AT 18,4; INK 2; BRIGHT 1;"Wrong! It was ";r$
  60 PAUSE 50
  62 NEXT n
  64 CLS
  66 PRINT AT 4,10; INK 5;"Score: ";sc;" out of 4"
 500 DATA "Closest planet to the Sun?","Mercury","Venus","Earth","Mars","a"
 510 DATA "Who built the pyramids?","Romans","Egyptians","Vikings","Greeks","b"
 520 DATA "Capital of France?","London","Berlin","Madrid","Paris","d"
 530 DATA "Instrument with 88 keys?","Guitar","Drums","Violin","Piano","d"

Q1 of 4 with header bar and score

The FOR n = 1 TO 4 loop runs the entire question sequence: read, display, input, check, score. The header bar shows “Q1 of 4” and the running score. CLS between rounds gives each question a fresh screen.

Four DATA lines at the bottom hold four complete questions. The loop count and DATA count must match — if you add a fifth question, change the loop to FOR n = 1 TO 5.

Score Tracking

LET sc = sc + 1 on line 50 only runs when the answer is correct, because the GO TO 60 skips it on wrong answers. After all four rounds, line 66 prints the total.

Try This

Six questions. Add two more DATA lines and change the loop to FOR n = 1 TO 6. No other code changes needed.

Show the correct answer. On the wrong path, print "Wrong! It was "; r$ so the player sees which letter was right.

What You’ve Learnt

  • Multiple values per READREAD q$, a$, b$, c$, d$, r$ pulls six values
  • DATA structure — question, four options, correct letter per line
  • Loop and DATA — the FOR count must match the number of DATA sets
  • Running score — increment only on the correct path