WEEK 4 DATE: ..............................
TOPIC: BASIC PROGRAMMING III
Learning Objectives:
At the end of this lesson students should be able to:
List BASIC Arithmetic Expressions; (i)√b2 -4ac2a (ii) (x-y)/(x+y) (iii) (a+b) + c/Sin d
State the application of each built-in-functions
Write BASIC notations of algebraic expression using built-in-functions
Write simple programs using built-in-functions; (i)find square root of numbers within
a given range
BASIC Notation/Symbols of Algebraic Expressions
(i) b2– 4ac/2a
Solution: SQR B**2 – 4*A*C/2*A OR SQR B^2 – 4*A*C/2*A
(ii) (x-y)/(x+y)
Solution: (x-y)/(x+y)
(iii) (a+b) + c/Sin d
Solution: (iii) (a+b) + c/SIN (d)
(iv) ex+y –Sin (x +ny)
Solution: (e^x+y- SIN(x+n*y))
(v) B = 1/4ac
Solution: B=1/4 (a*c)
(vi) A=∏r²
Solution: Area=PI*r**2 or PI*r^2
S ub-topic 2: BASIC Program to solve problems.
Example 1: Write a BASIC program to find square root of numbers within a given range.
Solution
INPUT “Lower range value....” LRNG
INPUT “UPPER range value...”, URNG
FOR I= LRNG TO URNG
SQR= 1** (1/2) // calculate the square root of the next number
ISQR= INT (SQR) // convert the square root to integer
PRINT “Square root of; ”1; “is “; ISQR
PRINT
NEXT I
END/STOP
Example 2: Write a BASIC program to find the SINE, COSINE and TANGENT of numbers.
FOR J= 1 TO 10
INPUT “Enter the next value/ number”; NUM
S= SIN (NUM)
C= COS (NUM)
T= TAN (NUM)
PRINT “Number “;J; “SINE = “;S; “COSINE =”;C;” TANGENT = “;T
NEXT J
END
Class Activities:
1. State four built-in functions.
2. State the use of the following built-in functions: a. RND (X) b. ABS (X)
3. What is the meaning of these BASIC functions? LOG, TAN, and ABS.
4. Which Mathematical operator has two notations in BASIC?
READING ASSIGNMENT
Read the topic “Internet” and summarize in one and half pages.
WEEKEND ASSIGNMENT
1. Write BASIC notation for:
a. A= (-b-d) divided by 2c
b. Z= x divided by y-c
c. C= 9c divided by 5 plus 32.
2. Write BASIC program to compute the square root of numbers from 10-40.