The content is just an excerpt from the complete note for SS3 Second Term Computer Studies Lesson Note – BASIC Programming II (One-dimensional array). Check below to download the complete DOCUMENT

WEEK 4                                                                                

TOPIC: BASIC Programming III (One-dimensional array)

CONTENTS

Write BASIC program to:

(a) State data in a vector of 10 integers with and without a FOR_NEXT statement etc

(b) Calculate the average of a one-dimensional array with 100 numeric value

(c) Calculate the area of 10 different rectangles with and without the WHILE_END statement

(d) Output the sum of the first 100 integers

(e) Output the value elements of a given array.

Sub-topic 1

  1. Write a program to put 10 integers into the memory and print them on the screen.

DIM A(10)

FOR 1 = 1 TO 10

READ A (1) // OR INPUT A (1) in an interactive session, i.e. through keyboard

PRINT A(1) // The PRINT statement output data/value of A(I) on the screen

NEXT I

DATA 80, 60, -10, 11, 100, 8, 99, 67, 9, 14 //DATA statement not required if INPUT

END // Statement is used

Calculate the average of a one-dimensional array with 100 numeric values.

REM using WHILE…END

DIM value(100)

Count = 1

Total = 0

WHILE count < 101

Total = total + valu(count)

Count = count + 1

PRINT “total =”, total

PRINT Average=”, total/100

END

To gain full access to the note: DOWNLOAD FILE

SEE ALSO  SS3 Second Term Government Lesson Note – E-Government

Copyright warnings! Do not copy.