BASIC keywords (Reserved words)

BASIC Keywords (Reserved Words) are special words built into the BASIC programming language with fixed meanings. You cannot use them as variable names because the computer recognizes them as commands. Examples include PRINT, INPUT, LET, and IF-THEN.

Quick Summary

  • Reserved words have special functions in BASIC programs
  • Cannot be used as variable names or labels
  • Always written in UPPERCASE in traditional BASIC
  • Essential for controlling program flow and data handling
  • Common in WAEC/NECO Computer Studies questions

What Are BASIC Keywords?

Think of BASIC keywords as the grammar rules of programming. Just as you cannot use a verb where a noun should be in English, you cannot misuse keywords in BASIC. These words tell the computer what action to perform.

When you write a BASIC program, the computer scans your code looking for these special words. For example, when it sees PRINT, it knows you want to display something on the screen. When it sees INPUT, it knows you want the user to type something.

Nigerian students often make mistakes by trying to name variables “INPUT” or “PRINT”. This causes errors because the computer gets confused between your variable and the keyword.

Categories of BASIC Keywords

1. Input/Output Keywords

PRINT – Displays text or values on screen

Example: PRINT “Welcome to WAEC exam”

INPUT – Accepts data from keyboard

Example: INPUT “Enter your JAMB score”; SCORE

READ/DATA – Reads values from DATA statements

Example: READ NAME$, AGE

2. Program Control Keywords

IF…THEN…ELSE – Makes decisions based on conditions

Example: IF MARK >= 50 THEN PRINT “Pass” ELSE PRINT “Fail”

FOR…NEXT – Creates loops that repeat a fixed number of times

Example: FOR I = 1 TO 10: PRINT I: NEXT I

WHILE…WEND – Repeats while condition is true

GOTO – Jumps to specific line number

GOSUB/RETURN – Calls and returns from subroutines

3. Variable Assignment Keywords

LET – Assigns values to variables (optional in modern BASIC)

Example: LET PRICE = 5000

DIM – Declares array dimensions

Example: DIM STUDENTS(30)

4. Program Structure Keywords

REM – Adds remarks/comments (ignored during execution)

Example: REM This calculates CGPA

END – Marks program termination

STOP – Pauses program execution

5. Logical/Relational Keywords

AND – Both conditions must be true

OR – At least one condition must be true

NOT – Reverses logical value

Complete List of Common BASIC Keywords

Keyword Category Purpose Example
PRINT I/O Display output PRINT “Hello”
INPUT I/O Accept input INPUT A
LET Assignment Assign value LET X = 10
IF-THEN Control Conditional IF X > 5 THEN PRINT X
FOR-NEXT Control Loop FOR I=1 TO 10
GOTO Control Jump to line GOTO 100
GOSUB Control Call subroutine GOSUB 500
RETURN Control Exit subroutine RETURN
READ I/O Read from DATA READ NAME$
DATA I/O Store values DATA 10, 20, 30
DIM Declaration Define array DIM A(50)
REM Documentation Add comment REM Calculate total
END Control End program END
STOP Control Pause program STOP
STEP Control Loop increment STEP 2
TO Control Loop limit TO 100
AND Logical Both true IF A>5 AND B<10
OR Logical Either true IF X=1 OR Y=2
NOT Logical Reverse logic IF NOT (X>10)

Why You Cannot Use Keywords as Variable Names

Many students try code like this:

LET PRINT = 100

This causes an error. The computer sees PRINT and expects you to display something, not store a value. Always use descriptive variable names instead:

  • ✓ TOTAL_SCORE instead of TOTAL (TOTAL might be reserved)
  • ✓ STUDENT_NAME$ instead of NAME$ (NAME might conflict)
  • ✓ EXAM_GRADE instead of GRADE

Sample BASIC Program Using Multiple Keywords

10 REM Program to calculate average of three subjects
20 DIM SUBJECTS(3)
30 PRINT "Enter marks for three subjects"
40 FOR I = 1 TO 3
50   INPUT "Enter mark"; SUBJECTS(I)
60 NEXT I
70 LET TOTAL = 0
80 FOR I = 1 TO 3
90   LET TOTAL = TOTAL + SUBJECTS(I)
100 NEXT I
110 LET AVERAGE = TOTAL / 3
120 IF AVERAGE >= 50 THEN PRINT "Pass" ELSE PRINT "Fail"
130 END

This program uses: REM, DIM, PRINT, FOR-NEXT, INPUT, LET, IF-THEN-ELSE, END

Common WAEC Exam Mistakes

  • Using keywords as variable names – “INPUT” or “DATA” as variables causes errors
  • Wrong spelling – Writing “PRIN” instead of “PRINT” or “INPT” instead of “INPUT”
  • Mixing keywords – Using GOTO without line numbers, or FOR without NEXT
  • Case sensitivity confusion – While traditional BASIC uses UPPERCASE, some versions accept lowercase
  • Missing required pairs – FOR without NEXT, GOSUB without RETURN, IF without THEN
  • Using = for comparison in IF statements without proper syntax

Practice Questions

Multiple Choice Questions

1. Which keyword is used to display output in BASIC?
a) SHOW
b) DISPLAY
c) PRINT ✓
d) OUTPUT

2. The keyword used to accept user input from keyboard is:
a) GET
b) INPUT ✓
c) READ
d) ACCEPT

3. Which pair of keywords must always be used together in BASIC?
a) PRINT and INPUT
b) FOR and NEXT ✓
c) LET and GOTO
d) READ and PRINT

4. The keyword REM is used to:
a) Remove variables
b) Add comments to programs ✓
c) Remember values
d) Repeat commands

Essay/Theory Questions

1. Explain what reserved words are in BASIC programming and state FOUR examples. (5 marks)

Tip: Define clearly, then list four keywords with their functions.

2. Write a BASIC program that uses at least SIX different keywords to calculate the sum of two numbers entered by the user. (8 marks)

Tip: Include REM, INPUT, LET, PRINT, END, and one logical operator if possible.

3. Distinguish between the following pairs of BASIC keywords: (6 marks)
(a) READ and INPUT
(b) GOTO and GOSUB
(c) END and STOP

Tip: Explain what each does and when to use each one.

Memory Aids

Input/Output keywords: P-I-R
PRINT – shows output
INPUT – gets input
READ – reads data

Loop keywords: F-W
FOR-NEXT – counted loops
WHILE-WEND – conditional loops

Control flow: I-G-G
IF-THEN – decisions
GOTO – jump to line
GOSUB – call subroutine

Related Topics

  • BASIC programming language structure
  • Variables and data types in BASIC
  • Control structures in programming
  • Loop statements (FOR-NEXT, WHILE-WEND)
  • Logical and relational operators

Leave a comment

not allowed!