JSS2: COMPUTER STUDIES - 2ND TERM
-
Introduction To Basic Language I | Week 17 Topics|1 Quiz
-
Introduction To Basic Language II | Week 22 Topics|1 Quiz
-
Computer Ethics I | Week 36 Topics|1 Quiz
-
Computer Ethics II | Week 42 Topics|1 Quiz
-
Safety Measures In Computer Environment | Week 53 Topics|1 Quiz
-
Computer Graphics Packages I | Week 63 Topics|1 Quiz
-
Computer Graphic Packages II | Week 76 Topics|1 Quiz
How To Write A Simple Basic Program
Topic Content:
- How To Write A Simple Basic Program
Example 2.2.1:
Write a simple Basic program to calculate the sum of 10, 15, 20 and 25.
Solution
Let A, B, C and D represent the four values. Let SUM = A + B + C + D
10 REM: SUM OF FOUR VALUES
20 CLS
30 LET A = 10
40 LET B = 15
50 LET C = 20
60 LET D = 25
70 LET P = A+B+C+D
80 PRINT P
90 END
Example 2.2.2:
Write a simple Basic program to calculate the perimeter (P) of a rectangular object whose length (L) is 20 meters and width (W) is 5 meters. Formula for perimeter = 2(L+W)
Solution:
10 REM: PERIMETER OF AN OBJECT
20 CLS
30 LET L = 20
40 LET W = 5
50 LET P = 2*(L+W)
60 PRINT P
70 END
Summary:
1. BASIC is meant for beginners as one of the most popular computer languages.
2. The Interpreter is a set of instructions that translates source programs in BASIC to machine codes.
3. Data representation involves the use of alphabets, numbers, strings and some special symbols.
4. There is a special order to be followed in evaluating mathematical problems in BASIC.
5. There are keywords like LET, EDIT, LOAD etc in BASIC language.
6. There are function keys which make the use of BASIC language flexible.