BASIC PROGRAMMING I.
Computer Science ICT SSS2 THIRD Term
WEEK 2
BASIC PROGRAMMING I
Content
KEYWORDS IN BASIC PROGRAMMING LANGUAGE
This is also referred to as a BASIC statement or a reserved word. It is an instruction in BASIC, which has a specific means to the compiler or interpreter.
- REM STATEMENT
The REM statement is a remark statement. It is used to insert remarks in the program. Such remarks are used to explain what the program is all about.
Example:
10 REM This program finds the average of 5 numbers
- LET STATEMENT
The LET statement is used to assign (or give) values to variables.
Examples:
10 LET A = B + C
- INPUT STATEMENT
Input is used to assign or give values to variables while a program is running. It can be used with both numeric and string variables.
Examples:
10 INPUT A, B, C
- PRINT STATEMENT
The print statement tells your computer to display the output of the executed program on the screen of the monitor (VDU).
Example:
10 PRINT SUMS
- END STATEMENT
End Statement is an instruction used to terminate the program. Once the computer encounters END statement, it automatically terminates the program.
50 END
- RUN STATEMENT
The RUN statement is used to execute a program. In Q-BASIC, F5 is used to RUN a program. Note that the program will not RUN if any mistake or error is detected in it.
BASIC ARITHMETIC OPERATORS
The following are arithmetic operators in BASIC organized in their order of execution:
() Bracket
˄ Exponential
/ Division
* Multiplication
+ Addition
- Subtraction
Basic must follow the above order during the execution of the program. In Mathematics, we are familiar with the principle of evaluating algebraic expression using BODMAS but in BASIC programming Language, it is called BEDMAS
BASIC ARITHMETIC EXPRESSION
Algebraic expressions are similar in a way to BASIC arithmetic expressions except for differences in some of their operators.
The following are algebraic expressions and their corresponding BASIC arithmetic expression.
|
Algebraic Expression |
BASIC Arithmetic Expression |
|
a+b |
A+B |
|
a-b |
A-B |
|
a÷b |
A/B |
|
b5 |
B˄5 |
|
a=b*h |
A=B*H |
|
X=am-by+c/z |
X=A*M-B*Y+C/Z |
|
A=(-b+d) 2c |
A=(-B+D)/(2*C) |
|
X |
X= -B+ (SQR(B˄2-4*A*C))/(2*A) X= -B -(SQR(B˄2-4*A*C))/(2*A) |
|
(x-y) (x+y)
|
(X-Y)/(X+Y) |
READING ASSIGNMENT: HiiT @ School, Computer Studies for Senior Secondary Education. Chapter Five, pages 34-36, 110.
WEEKEND ASSIGNMENT
OBJECTIVES
- ……………….. statement is used to assign (or give) values to variables
- REM (b) INPUT (c) LET
- ………………… statement is used to execute a program
- INPUT (b) RUN (c) END
- ………………… A statement is an instruction used to terminate the program.
- INPUT (b) RUN (c) END
- ……………… principle of evaluating an arithmetic expression in BASIC programming Language.
- BODMAS (b) BODMES (c) BEDMAS
- …………….. statement is used to assign or give values to variables while a program is running
- INPUT (b) RUN (c) END
THEORY
- Write the function of the following BASIC keywords
- LET (b) INPUT (c) PRINT (d) REM (e) RUN
- Rewrite the following algebraic expressions as a BASIC arithmetic expression.
- Y= hk2 (b)

(c) 
(d) 


