Introduction To Programming
Introduction To Programming
PROGRAMMING
Introduction to Programming
(Definition of Computer Program )
A computer program is a collection of instructions that performs a specific task when executed
by a computer.
A computer requires programs to function, and typically executes the program's instructions in
a central processing unit
A computer program is usually written by a computer programmer in a programming language.
From the program in its human-readable form of source code, a compiler can derive machine
code—a form consisting of instructions that the computer can directly execute. Alternatively, a
computer program may be executed with the aid of an interpreter.
Programming language is a syntax, grammar, and symbols or words used to give instructions to
a computer
Generation of Programming Language
Generation of Programming Language
First Generation of Programming Language (1GL)
Advantages / benefit
Disadvantages / Weaknesses
Advantages / Benefit
Disadvantages / Weaknesses
Advantages / Benefit
To relieve the programmer of the detailed and tedious task of writing
programs in machine language and assembly languages
To provide programs that can be used on more than one type of
machine with very few changes
To allow the programmer more time to focus on understanding the
user’s needs and designing the software required meeting those
needs
The programmer spends less time developing software with a high-
level language than with assembly or machine language because
fewer instructions have to be created
Third Generation of Programming Language (3GL)
Disadvantages / Weaknesses
A high-level
language has to be translated into the
machine language by a translator, which takes up time
The object code generated by a translator might be
inefficient compared to an equivalent assembly
language program
Fourth Generation of Programming Language (4GL)
Advantages / Benefit
Disadvantages / Weaknesses
Advantages / Benefit
Logic based languages are able to represent the real
world more accurately
Prolog is able to derive new rules from the existing rules
contained within the knowledge base
Fifth Generation of Programming Language (5GL)
Disadvantages / Weaknesses
It can be very difficult to design a database that accurately
represents relationships
Prolog is not best suited to solving complex arithmetical
computations
Prolog programs are not best suited to the current PC
architecture (sequential execution) and are best optimised on
parallel architectures (fifth generation computers)
SUMMARY GENERATION PROGRAMMING LANGUAGE
LANGUAGE TRANSLATORS
TRANSLATORS
ASSEMBLER
On the other hand, a compiler goes through the entire program and then translates the
entire program into machine codes.
A compiler is 5 to 25 times faster than an interpreter.
By the compiler, the machine codes are saved permanently for future reference.
On the other hand, the machine codes produced by interpreter are not saved.
An interpreter is a small program as compared to compiler.
It occupies less memory space, so it can be used in a smaller system which has limited
memory space.
They’re portable, which means they can run on different operating systems and platforms
COMPILER VS INTERPRETER
COMPILER VS INTERPRETER
5 Generations of Computer Program
CHERISTERISTIC
S
Advantages/
Name Level Translator Example
Disadvantages
1. The fourth generation languages are easier to use than the third generation languages.
a) State two examples of the fourth generation languages.[2]
SQL, Prolog [1 mark each]
b) Describe two characteristics of the fourth generation languages.[4]
used GUI(Graphical User Interface) that enable the user and the computer to communicate with
each other in the easier way.
used to generate user specific report so that specific information can be generates to a specific user.
c) State the two similarities between the third generation languages and the fourth generation languages.
[1]
The language is easy to understand.
The language is easy to write.
ANSWER - EXERSISES 2
c. Function of a compiler is to translate source code from a high-level programming language to a lower
level language into object code or machine code to create an executable program. [2]
i. C is a General Purpose Programming Language This means C can be used to write a variety of
applications. It is often referred to as a “system programming language.”
ii. C is a middle level language, which means it combines the features of high level language with the
functionality of an assembly language.
iii. C is a structured programming language, which means as a programmer, you are required to divide a
problem into a several different modules or functions.
ANSWER - EXERSISES 2
iv. C is renowned for its simplicity and is easy to use because of its structured approach. It has a vast
collection of keywords, operators, built-in functions and data types which make it efficient and powerful.
v. C is portable, which means a C program runs in different environments. C compilers are available for all
operating systems and hardware platforms. Additionally, you can easily write code on one system and
port it to another.
vi. C is popular not just because it can be used as a standalone programming language, but also as it can be
used as an interface to other more visual languages.
vii. C is a very flexible language; it is convenient and portable, like a high level language and flexible like a
low level language. It can be interfaced with other programming languages.
viii. C is super fast. The compilation and execution of programs is much faster on C than with most other
languages.
ANSWER - EXERSISES 3