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
Arithmetic Operations In Basic Programs
Topic Content:
- Arithmetic Operations In Basic Programs
- Order of Arithmetic Operations In Basic
1. Multiplication operation in Basic language uses the asterisk (*), for example, Let C = A*B
2. Division operation in Basic uses slash (/)
3. Addition in Basic language uses the plus sign (+)
4. Subtraction in Basic language uses the minus sign (-)
5. Exponentiation operation in Basic uses the up-caret sign (^) to raise the number to a power, for example, Print A^2 * B^2.
Order of Arithmetic Operations In Basic:
1. Parenthesis/Brackets: these are worked out first from the inner-most parenthesis outwards from left to right
2. Exponentiation: this is marked next from left to right
3. Multiplication and Division: this follows from left to right
4. Addition and Subtraction: it is formed in order of addition and subtraction from left to right.
All operations in the first order must be completed before moving to the next order of operation. For example,
PRINT (2+4) ^2+4 *2.
Firstly, we do the parenthesis or bracket; (2+4) = 6
Then, exponentiation; 6^2 = 36.
Then multiplication; 4*2 = 8.
Then, finally, addition: 36 + 8 = 44
The computer will display 44
Example 1.2.1:
Evaluate these BASIC statement expressions:
(i) 5*(6+2)^3
(ii) (4/2) + (15/5)*3^3
(i) 5*(6+2)^3
Solution
Firstly, we do the parenthesis or bracket; (6+2) = 8
5*8^3
Then, exponentiation; 8^3 = 512.
Then multiplication; 5*512 = 2560
(ii) (4/2) + (15/5)*3^3
Solution
Firstly, we solve the equation in the bracket or parenthesis 4/2 = 2 and 15/5 = 3
2 + 3* 3^3
Then, exponentiation; 3^3 = 27
2 + 3* 27
Then multiplication; 3*27 = 81
2 + 81
Finally, we add the values that are left
= 83