MAIN AIM: To help the students understand the meaning of BASIC and what it is used for.
SUBSIDIARY AIMS: By the end of the lesson, the students should be able to understand what programming language is all about.
- Define BASIC,
- Basic Menu and Keywords,
- Understand the functions of each BASIC keyword.
PERSONAL AIM: To assist the students understand programming using BASIC
ASSUMPTION: it is assumed that the students don’t know how to write simple computer program
ANTICIPATED PROBLEMS: the students don’t know how to write simple computer program using BASIC,
POSSIBLE SOLUTION: The teacher introduces the student to BASIC
TEACHING AIDS: marker, chalk, computer programming software (pythion)
STEP 1: DEFINITION OF BASIC
BASIC is the acronym for Beginners All Purpose Symbolic Instructional Code (BASIC)
It is a programming language for beginners because it is easy to use and understand, and because it contains the same major idea used in many other languages thought to be more difficult, such as Pascal.
BASIC was developed by John Kemeny and Thomas Kurtz in the mid-1960s.
Working with Basic Using Various Menus
NEW: New is used when you want to start a new program
OPEN: When you want to update a program that you already worked on, choose open and then choose the program that you wish to work on
SAVE: When you have saved a program once before and you want to save it again, choose save. Save your work often
SAVE AS: When you want to save a program for the first time, choose Save As. You then have to give your program a name. Your program name should not be more than 8 letters long.
PRINT:Choose print when you want to send your program to the printer.
Key BASIC STATEMENTS
Programming is an art that can be seen from different views. The keywords or the reserved words are the tools that we use in writing BASIC programs. They are instructions that are carried out by the program translator, i.e., the compiler and the interpreter. They include:
- PRINT,
- CLS,
- REM,
- READ
- GOTO,
- DATA
- FOR … NEXT,
- IF … THEN …ELSE,
- LIST
- LOAD / (OPEN),
- END,
- STOP
1. Remark Statement (REM): This is a remark. It does not affect the program in terms of instruction or command line.
a. REM: It is used in explaining what the program is all about. Example, 10 REM. Program to calculate average of numbers. This statement will appear as comment on the screen
2. Assignment Statement: This keyword is used in assigning values to variables, e.g. READ, DATA, LET, INPUT
a. READ statement: This is a statement used in giving values to variables. Usually READ statement has DATA statement with it.
Examples,
I 10 READ I,M,N
20 DATA 5,7,9
II 10 READ A,B,C
20 DATA 1,2,3
B. DATA statement: This statement is used in attaching strings of fixed characters and numeric data in BASIC. A DATA statement can have one piece of data or many. Either of these is called DATA element. DATA elements are separated by commas (,).
Examples,
I. 10 READ A,B,C,D
20 DATA 6,7,15,10
30 PRINT “SUM” = A+B+C+D
40 RUN
SUM =38
II. 10 REM PROGRAM TO SUM NUMBERS
20 READ X,Y,Z
30 DATA 15,10,20
40 PRINT “SUM” = X+Y+Z
SUM = 45
C. LET statement: This statement is used in attaching strings of fixed characters and numeric data in BASIC.
Examples,
I. 5 LET A = 50
10 LET B = 10
15 LET C = A + B
Here the lines are 5, 10, 15
II. 10 READ A, B,C,D
20 DATA 6,7,15,10
30 LET SUM = A +B + C + D
RUN
SUM = 38
D. INPUT statement: This statement is used assigning values to variables.
Examples,
I) 10 INPUT A
20 INPUT B
30 INPUT C
40 PRINT A, B, C
3. Program Terminator
These keywords are used to terminate the program, e.g. STOP AND END
a) STOP statement: This statement is used to terminate a program.
b) END statement: This statement is used to terminate a program.
Example,
10 REM
20 GOTO 50 (The program moves to line 50)
30 READ A, B ,C, D
40 PRINT “SUM” = A+B+C+D
50 STOP
4. Output Statement.
This keyword is reversed to display output from the computer, e.g. PRINT
a) PRINT statement: This statement is used to transmit or display output data from the computer. The PRINT statement is usually followed by a list of items to be displayed and each item is separated by a comma (,) or semi-colon (;)
Examples are:
I) 10 PRINT A, B, C
20 PRINT “X” =; “Y” = Y
This statement will cause the monitor to display whatever is stored in the non-numeric variables ABC and whatever is stored in X and Y.
II) PRINT (2*4)/2
The monitor will display 60
III) 5 LET A = 50
10 LET B = 10
15 LET C = A + B
20 PRINT C
The monitor will display 60
EVALUATION:
- Define the following;
(a) New (b) Open (c) Save (d) Save As Print
- Explain the following;
(a) Remark Statement (b) Assignment Statement (c) DATA statement (d) Let statement.
SUMMARY:
- BASIC is the acronym for Beginners All Purpose Symbolic Instructional Code (BASIC)
- It is a programming language for beginners because it is easy to use and understand, and because it contains the same major idea used in many other languages thought to be more difficult, such as Pascal.
- BASIC was developed by John Kemeny and Thomas Kurtz in the mid-1960s.
- New is used when you want to start a new program
- OPEN: When you want to update a program that you already worked on, choose open and then choose the program that you wish to work on
- SAVE: When you have saved a program once before and you want to save it again, choose save. Save your work often
- SAVE AS: When you want to save a program for the first time, choose Save As. You then have to give your program a name. Your program name should not be more than 8 letters long.
- PRINT: Choose print when you want to send your program to the printer.
- Programming is an art that can be seen from different views. The keywords or the reserved words are the tools that we use in writing BASIC programs. They are instructions that are carried out by the program translator, i.e., the compiler and the interpreter.
ASSIGNMENT:
- Define the following;
(a) New (b) Open (c) Save (d) Save As Print
- Explain the following;
(a) Remark Statement (b) Assignment Statement (c) DATA statement (d) Let statement.
CONCLUSSION: The students understand the meaning of BASIC and what it is used for
TEACHER’S EVALUATION: The students understand programming using BASIC
PREVIOUS LESSON: BASIC (I)
MAIN AIM: To help the students write BASIC programs for solving simple Mathematical calculations.
SUBSIDIARY AIMS: By the end of the lesson, the students should be able to understand what programming language is all about.
- How to write simple BASIC program,
- Write a BASIC program for finding the area of a Triangle,
- Write a BASIC program for solving simple interest.
PERSONAL AIM: To assist the students in writing simple BASIC programs.
ASSUMPTION: it is assumed that the students don’t know how to write simple computer program
ANTICIPATED PROBLEMS: the students don’t know how to write simple computer program using BASIC,
POSSIBLE SOLUTION: The teacher introduces the student to BASIC
TEACHING AIDS: marker, chalk, computer programming software (pythion)
STEP 1: Writing Simple Basic Programs
- Write a BASIC program to calculate the product of three numbers
Solution:
100 REM: Program to calculate the product of three numbers
200 LIST:
300 PROD
400 READ A, B, C
500 DATA 3, 4, 9
600 LET P = A*B*C
700 PRINT P
800 END
Note: The line number does not affect the program.
- Write a program to calculate the area of a circle. (Area= πr2)
Solution:
10 CLS
15 Program to calculate area of a circle
20 Let area = 3.142*r**2
25 PRINT area
30 END
- Write a program to calculate simple interest
Solution:
Algorithm to calculate S.I
STEP (1) Using pseudo code
S.I. = PRT
100
Begin
INPUT P, R, T
S.I. = (P*R*T)/100
PRINT 1
- Write a BASIC program to calculate the sum of two numbers
Solution:
REM a program to add 2 numbers
CLS
INPUT Number 1
INPUT Number 2
TOTAL = Number 1 + Number 2
PRINT “TOTAL”
END
- Write a BASIC program to find the average of 3 Numbers
Solution:
REM A program to find the average of 3 numbers
CLS
INPUT NUMBER 1
INPUT Number 2
INPUT Number 3
TOTAL = Number 1 + Number 2 + Number 3
AVERAGE = TOTAL/3
END
- Write a BASIC program to calculate the area of a triangle with base
Solution:
REM A program to find the average of 3 numbers
CLS
INPUT base
INPUT height
AREA = 0.5 base * height
EVALUATION:
- Write a program to find the product of four numbers using the ‘LET’ statement?
- Write a program to calculate the average of five numbers using the ‘INPUT’ statement?
ASSIGNMENT:
- Write a program to calculate simple interest using the ‘READ, DATA, LET, PRINT’ statements.
[Hint: S.I = PRT/100].
CONCLUSION:
TEACHER’S EVALUATION: The students understand programming using BASIC
MAIN AIM: To help the students write BASIC programs for solving simple Mathematical calculations.
SUBSIDIARY AIMS: By the end of the lesson, the students should be able to understand what programming language is all about.
- How to write simple BASIC program,
- Write a BASIC program for finding the area of a Triangle,
- Write a BASIC program for solving simple interest.
PERSONAL AIM: To assist the students in writing simple BASIC programs.
ASSUMPTION: it is assumed that the students don’t know how to write simple computer program
ANTICIPATED PROBLEMS: the students don’t know how to write simple computer program using BASIC,
POSSIBLE SOLUTION: The teacher introduces the student to BASIC
TEACHING AIDS: marker, chalk, computer programming software (python), computer Laboratory
STEP 1: Writing Simple Basic Programs
- Write a BASIC program to calculate the product of three numbers
Solution:
100 REM: Program to calculate the product of three numbers
200 LIST:
300 PROD
400 READ A, B, C
500 DATA 3, 4, 9
600 LET P = A*B*C
700 PRINT P
800 END
Note: The line number does not affect the program.
- Write a program to calculate the area of a circle. (Area= πr2)
Solution:
10 CLS
15 Program to calculate area of a circle
20 Let area = 3.142*r**2
25 PRINT area
30 END
- Write a program to calculate simple interest
Solution:
Algorithm to calculate S.I
STEP (1) Using pseudo code
S.I. = PRT
100
Begin
INPUT P, R, T
S.I. = (P*R*T)/100
PRINT 1
- Write a BASIC program to calculate the sum of two numbers
Solution:
REM a program to add 2 numbers
CLS
INPUT Number 1
INPUT Number 2
TOTAL = Number 1 + Number 2
PRINT “TOTAL”
END
- Write a BASIC program to find the average of 3 Numbers
Solution:
REM A program to find the average of 3 numbers
CLS
INPUT NUMBER 1
INPUT Number 2
INPUT Number 3
TOTAL = Number 1 + Number 2 + Number 3
AVERAGE = TOTAL/3
END
- Write a BASIC program to calculate the area of a triangle with base
Solution:
REM A program to find the average of 3 numbers
CLS
INPUT base
INPUT height
AREA = 0.5 base * height
EVALUATION:
- Write a program to find the product of four numbers using the ‘LET’ statement?
- Write a program to calculate the average of five numbers using the ‘INPUT’ statement?
ASSIGNMENT:
- Write a program to calculate simple interest using the ‘READ, DATA, LET, PRINT’ statements.
[Hint: S.I = PRT/100].
CONCLUSION:
TEACHER’S EVALUATION: The students understand programming using BASIC