: PROGRAMMING LANGUAGES
Computer programming is the specification of instructions that a computer follows to perform
a particular task.
A computer program is a sequence of instructions that tells a computer what to do and how to
do it.
A programming language is a language used to write instructions for the computer. Programming
language, like any human language has rules and grammar that governs the formation of a
statement.
The syntax of a language describes the possible combinations of symbols that form a correct
statement. The meaning given to these combinations of symbols is called semantics.
Levels of programming
1. Machine language: Is a system of instructions and data directly understood by the
computer’s central processing unit. These instructions and data are combinations of sequence
of bits (0’s and 1’s) with different patterns corresponding to different commands to the
machine.
2. Low level (Assembly) language: This language uses abbreviations or symbolic letter
codes (mnemonics) to write each machine-language instruction. The letter codes are used in
place of binary digits. Programs written in Assembly language are translated into machine
language by an Assembler.
3. High level language: The instructions of this language are written using words that are
very close to human languages and algebra-type expression. They are closer to human
understanding and are translated into machine language by a compiler or an interpreter.
Features/characteristics of each level of programming language
i) Machine language
1. These instructions consist of binary numbers (set of 0’s and 1’s)
2. This language is machine dependent i.e. instructions written for a particular type of
computer can only be executed on that particular computer(machine).
3. It is very hard for people to write and understand thus making the programs error prone.
4. Each CPU design has its own machine language, which is the set of instructions that the
CPU of that machine understands and executes.
ii) Low level ( or Assembly) language
1. Uses mnemonics (symbolic operation codes) and operands (symbolic storage address).
2. Machine dependent
3. For any assembly language instruction, one machine language instruction is generated.
4. It illustrates fundamentals of computer construction and operation.
iii) High level languages
1. Machine independent: programs written or compiled on one type of Computer can be
executed (run) on different type of computer that has different architecture.
2. It uses instructions that seem English-like and thus closer to human understanding.
3. Easy to detect errors
4. Consists of well-defined syntax and standard.
5. Requires a compiler to translate into machine language before the computer can execute
them.
6. Programs written in HLL are called source code and the compiled version is called object
code.
Comparison of levels of Programming Languages
MACHINE LANGUAGE ASSEMBLY LANGUAGE HIGH LEVEL LANGUAGE
Difficult to learn, write and It is difficult but easier than It is easier to learn, write and
debug machine language debug
It is machine dependent Machine dependent Machine independent
Does not require a translator Requires a translator called Requires a translator called a
Assembler compiler or interpreter
Instructions consist of binary Instructions consist of symbols Instructions consist of English-like
digits (1’s and 0’s) and mnemonics words, symbols and numeric.
Examples of Programming Language
The following are some of the many programming languages:
Ada, Algol, APL, BASIC, C, C++, C#, COBOL, FORTRAN, Java, JavaScript, LISP, Pascal, PHP, Perl,
Python, Visual Basic etc.
TOPIC 5: BASIC Programming language
The BASIC programming language was developed in 1964 by John G. Kemeny and Thomas
Kurtz at Dartmouth College. BASIC is an acronym that stands for “Beginner’s All-Purpose
Symbolic Instruction Code”
Basic Character Set
A character set is simply a list of letters, numbers and symbols that provide one with the
characters used in a particular language. BASIC as a language has its own character set, they
include the following:
Alphabets characters (A to Z or a to z)
Numeric character (0, 1 to 9) including hexadecimal characters.
Special characters (such as $,#,!, ^ etc.) that perform special functions in BASIC
Arithmetic operators
CHARACTER NAME USE
* Asterisk For multiplication, e.g. A*B or (3*5)
- Minus For subtraction, e.g. M-N or (4-1)
+ Plus For addition, e.g. K+N or (1+6)
/ Forward slash For real division, e.g. A/B or (7/3)=2.33
\ Bask slash For integer division, e.g. P\G or (7\3)=2
^ Caret For exponentiation, e.g. A^B or (7^3)
Relational (Comparison) Operator
CHARACTER NAME USE
= Equal to A=B
> Greater than A>B
< Less than A
>=
Greater than or Equal to
A >=B
<=
Less than or Equal to
A <= B
Data types
Data type is a description of the set of values and the basic set of operation that can be
applied to values of the type.
i) Integers: a positive or negative number without decimal. It has a range of values
from -32,768 to 32,767. Each value is stored using 2 bytes of memory (storage) space.
ii) Real numbers: numbers with fractional parts or with a decimal point. It is stored
using 4 bytes of memory space.
iii) Boolean: consist of only two values; “YES and NO” or “True or False” or 1 or 0.
iv) String: a sequence of characters in double quote. For example, “Computer Studies”
is a string value with 16 characters. Each character is stored using 8 bits (one byte) in
the ASCII character set and two byte in the UNICODE character set. Alphabet is
represented in ASCII.
Keyword
Keywords are words that have special meaning and function in BASIC. Such words must be
used strictly according to their functions, otherwise the computer will respond with error
message.