WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
POLITEKNIK MALAYSIA
1. DFC1023
PROBLEM SOLVING & PROGRAM DESIGN
C H A P T E R 1
I N T R O D U C T I O N T O P R O G R A M M I N G
L A N G U A G E ( 1 W E E K )
2. AT THE END OF THIS CHAPTER, STUDENTS SHOULD
BE ABLE TO:
1. Discuss the Evolution of programming language
History of programming languages
Various categories of programming languages
2. Describe fundamentals of programming languages
Terminologies in programming: programmer, program and
programming.
Language translator : Assembler, compiler and translator.
Relate the programming language application in real life.
3. HISTORY OF PROGRAMMING LANGUAGE
Programming Language - A set of rules and reserved
words (keywords) that can be used to tell a computer
what are the operations to be done.
Artificial language composed by a fixed vocabulary and
set of rules is used to create instructions for the
computer to follow.
Now, there are over 200 programming languages in
the world.
For example: Cobol, Pascal, C, C++, JAVA and Fortran.
5. CATEGORIES OF PROGRAMMING LANGUAGE
First Generation Language (Machine Languages)
The lowest level of language.
Uses 1s and Os / binary digits to represents data and instructions
Examples: 0 represents “off” and 1 represents “on”.
The only language that the computer could understand (does not
require translator).
6. Advantage
• The computer processes the instructions in
machine language very quickly.
Disadvantages
• Programmers must have knowledge of the machine
hardware and its configuration.
• Programmer needs to remember a number of
binary codes to write machine language programs.
• Machine language programs are very difficult to
debug.
CATEGORIES OF PROGRAMMING LANGUAGE
• First Generation Language (Machine Languages)
7. CATEGORIES OF PROGRAMMING LANGUAGE
Second Generation Language (Assembly Languages)
Known as symbolic language.
It uses mnemonic codes - a symbol chosen to help user to remember
replace “0” and “1”
For example, A represented ADD and S represented SUM
Computer does not understand the language so it needs an assembler to
translate the program to machine language.
8. Advantages
• It is easy for programmers to remember the
alphanumeric codes than the binary codes.
• Debugging is very easier when compared to
machine language.
Disadvantage
The major disadvantage is that, it is machine
dependent.
CATEGORIES OF PROGRAMMING LANGUAGE
Second Generation Language (Assembly Languages)
9. CATEGORIES OF PROGRAMMING LANGUAGE
3rd Generation Languages
It is called a procedural language.
Translation is done by compiler / interpreter.
Example: C, C++, FORTRAN, COBOL and BASIC.
Example: Program in
Basic to compute
the average of three
numbers.
‘BASIC PROGRAM
‘AVERAGING THREE INTEGERS
PRINT “Mengira Purata”
PRINT “---------------------“
PRINT “Nilai A = “; 20
PRINT “Nilai B = “; 30
PRINT “Nilai C = “; 40
PRINT “Purata tiga nombor ialah “;
(20+30+40)/3
END
10. Advantages
•Easier to learn and understand than an assembler
language as instructions (statements) that resemble
human language or the standard notation of
mathematics.
•Have less-rigid rules, forms, and syntaxes, so the potential
for error is reduced.
Disadvantages
Less efficient than assembler language programs
and require a greater amount of computer time for
translation into machine instructions.
CATEGORIES OF PROGRAMMING LANGUAGE
3rd Generation Language (Assembly Languages)
11. CATEGORIES OF PROGRAMMING LANGUAGE
4th Generation Languages
Program is written in English-like statements.
It is a short programming language where the operation needs a
few lines instead of hundreds of lines.
It is a non-procedural language.
Known as query language, which can be used to retrieve data
from database.
Example: PROLOG, FOCUS, LISP and SQL.
Advantages:
a. Result-oriented where they emphasize on
what instead of how.
b. It is simpler and easier, so programmers
and non-programmers can use this
language with minimum training.
Create table order
( OWNERID INTEGER NOT NULL,
ITEM CHAR (40) NOT NULL);
SQL Language
12. CATEGORIES OF PROGRAMMING LANGUAGE
5th Generation Languages
A programming language that resembles human language.
Known as knowledge-based language.
Translates human instructions into code (machine
language) where a computer can understand.
The use of a natural language to
access knowledge base is called
knowledge-based system.
Example: Expert system that stores
knowledge of an expert. For
example, expertise of a doctor or
engineer.
13. Advantages
• Programs are almost machine-independent.
• It is not necessary for the programmer to have
knowledge about computer hardware.
• It is very easy to learn and write programs in high-
level languages.
Disadvantages
Programs written in high-level languages are
slower in execution than the programs written
using low-level languages.
CATEGORIES OF PROGRAMMING LANGUAGE
5th Generation Language
14. TERMINOLOGIES IN PROGRAMMING
Programmer is a person who writes the
program.
Program is a set of step-by-step instructions that
directs a computer to perform a specific task
and to produce the required results.
Programming is a process of designing /
creating a program.
15. LANGUAGE TRANSLATORS
A translator is a program that:
Checks syntax of a program to ensure the programming
language is used correctly, by giving you the syntax-error
messages, which is known as diagnostics.
Produces descriptive error messages known as syntax-
error to programmer if there are errors in the programs.
Translates a program into language that the computer can
understand.
16. LANGUAGE TRANSLATORS
Syntax – set of rules to be followed when writing a
program, these rules are similar to the grammatical rules
in English.
Syntax Error – error in the use of a programming
language.
Example in C: Statement: clrscr()
If semicolon (;) is not placed after statement, a
message will display:
“Error DIT103.CPP: Declaration syntax- error”
The correct syntax is: clrscr();
17. TYPES OF TRANSLATOR
1. Assembler
•Translates the whole program at one time.
•Also called assembler program.
•A program, which is used to convert assembly language to
machine language.
18. TYPES OF TRANSLATOR
2. Compiler
Translate the whole program at one time.
Translates the source code, for example COBOL language to
machine language.
Used to translate C, COBOL and other language.
19. TYPES OF TRANSLATOR
3. Interpreter
o Program that translates a high level language to machine
language.
o It translates one line at a time and executes each line
after it is translated.
o Displays feedback as the error occurred.
o Used to translate BASIC and SQL language.