(a) Define programming language.
(b) Write the 5 following mathematical expressions in BASIC notation:
(i) x (w + y)\(^2\) (ii) ab/cd (ii) p = 2 (1+b).
(c) Write a simple BASIC program to calculate the area (A) of a rectangle with length (l) and breath (b).
(d) List two levels of programming language.
(a) Definition of programming language
A programming language is a set of symbols, words and grammatical rules (syntax) used to write instructions that a computer can understand and carry out to solve a problem. Examples are BASIC, C, Java and Python.
(b) The expressions in BASIC notation
- (i) \(x(w + y)^2\) is written as
X * (W + Y) ^ 2 - (ii) \(\dfrac{ab}{cd}\) is written as
(A * B) / (C * D) - (iii) \(p = 2(1 + b)\) is written as
P = 2 * (1 + B)
(c) BASIC program to calculate the area (A) of a rectangle
The area of a rectangle is length multiplied by breadth, \(A = l \times b\).
10 REM PROGRAM TO FIND AREA OF A RECTANGLE
20 INPUT "ENTER LENGTH"; L
30 INPUT "ENTER BREADTH"; B
40 A = L * B
50 PRINT "AREA OF RECTANGLE = "; A
60 END
(d) Two levels of programming language
- Low-level language (machine language and assembly language).
- High-level language (such as BASIC, C, Java and Python).