(a) What is: (i) an array; (ii) a syntax error? (b) Write QBASIC program that will input multiples of Three between 1 and 20 into a one-dimensional array an...

Assessment: WAEC SSCE - Computer Studies - 2018 (Essay) Subject: Computer Studies

Question 1 Report

(a) What is: (i) an array; (ii) a syntax error?

(b) Write QBASIC program that will input multiples of Three between 1 and 20 into a one-dimensional array and display the output on the screen.

(c) Convert D5FA,, to binary.

Answer Details

(a) Definitions

(i) An array: An array is a data structure that holds a fixed number of data items of the same data type under a single variable name, with each item (element) identified by an index or subscript. For example, one array can store many students' scores, referred to as SCORE(1), SCORE(2), and so on.

(ii) A syntax error: A syntax error is a programming error that occurs when a statement breaks the grammatical rules of the programming language (for example a misspelt keyword, a missing bracket or a wrong statement structure). Such errors are detected by the translator (compiler or interpreter) and prevent the program from running until corrected.

(b) QBASIC program: multiples of three between 1 and 20 into a one-dimensional array

The multiples of three between 1 and 20 are 3, 6, 9, 12, 15 and 18 (six values).

REM Store multiples of 3 between 1 and 20 in an array
CLS
DIM M(6)
K = 0
FOR N = 1 TO 20
    IF N MOD 3 = 0 THEN
        K = K + 1
        M(K) = N
    END IF
NEXT N
PRINT "Multiples of three are:"
FOR I = 1 TO K
    PRINT M(I)
NEXT I
END

The loop tests each number from 1 to 20; when a number divides exactly by 3 (N MOD 3 = 0) it is stored in the next array position and later displayed.

(c) Convert \(D5FA_{16}\) to binary

Replace each hexadecimal digit with its 4-bit binary equivalent:

\[D = 1101,\quad 5 = 0101,\quad F = 1111,\quad A = 1010\]

\[\therefore D5FA_{16} = 1101\,0101\,1111\,1010_2 = 1101010111111010_2\]

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning