0% found this document useful (0 votes)
16 views7 pages

Basic Programming with Loops and Vectors

This document outlines a BASIC programming lesson focused on loop statements, including FOR–NEXT and WHILE–END, and their applications in writing simple programs. It covers how to store and process data in vectors (arrays) and calculate averages of numeric arrays. Additionally, it includes WAEC questions for practical application of the concepts learned.

Uploaded by

debbynnamdi0
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Basic Programming with Loops and Vectors

This document outlines a BASIC programming lesson focused on loop statements, including FOR–NEXT and WHILE–END, and their applications in writing simple programs. It covers how to store and process data in vectors (arrays) and calculate averages of numeric arrays. Additionally, it includes WAEC questions for practical application of the concepts learned.

Uploaded by

debbynnamdi0
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

BASIC PROGRAMMING I

(BASIC LANGUAGE)
BY THE END OF THIS LESSON, STUDENTS SHOULD BE
ABLE TO:
- REVIEW AND APPLY FOR–NEXT AND WHILE–END
STATEMENTS IN BASIC
- WRITE SIMPLE BASIC PROGRAMS USING LOOPS
- STORE AND PROCESS DATA IN VECTORS (ARRAYS)
- CALCULATE AVERAGES OF NUMERIC ARRAYS
REVIEW OF LOOP STATEMENTS

FOR–NEXT Statement
Used for count-controlled loops.
FOR i = 1 TO 10
PRINT i
NEXT i
➝ Prints numbers 1 to 10.
WHILE–END Statement: Used for condition-controlled
loops.

LET i = 1
WHILE i <= 10
PRINT i
LET i = i + 1
END WHILE
➝ Prints numbers 1 to 10.
VECTOR OF 10 INTEGERS
With FOR–NEXT:
DIM A(10)
FOR i = 1 TO 10
READ A(i)
NEXT i
DATA 5,10,15,20,25,30,35,40,45,50
Without FOR–NEXT:
DIM A(10)
LET A(1) = 5
LET A(2) = 10
LET A(3) = 15
...
LET A(10) = 50
Average of 100 Numeric Values
DIM A(100)
LET SUM = 0
FOR i = 1 TO 100
READ A(i)
LET SUM = SUM + A(i)
NEXT i
LET AVG = SUM / 100
PRINT "Average = "; AVG
DATA 1,2,3,4,...,100
WAEC Questions
• Write a BASIC program using FOR–NEXT to print the first 20
odd numbers.
• State two differences between FOR–NEXT and WHILE–END
loops.
• Write a BASIC program to calculate the sum of integers from
1 to 50.
• Explain what is meant by a vector in programming.

You might also like