Sie sind auf Seite 1von 22

DFC1023

PROBLEM SOLVING &PROGRAM


DESIGN

CHAPTER 1

INTRODUCTION TO PROGRAMMING
LANGUAGE
AT THE END OF THIS CHAPTER,
STUDENTS SHOULD BE ABLE TO:
1. Discuss the evolution of programming language
Describe the history of programming language and
approaches
2. Differentiate the various categories of programming
languages with examples of language and technology
Machine Languages
Assembly Languages
3rd Generation Languages
4th Generation Languages
5th Generation Languages
3. Describe fundamentals of programming languages
State the definitions of programmer, program and
programming
Explain the following language translators
Relate the programming languages application in real life
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.
HISTORY OF PROGRAMMING LANGUAGE
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).
CATEGORIES OF PROGRAMMING LANGUAGE
First Generation Language (Machine Languages)
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
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.
CATEGORIES OF PROGRAMMING LANGUAGE
Second Generation Language (Assembly Languages)
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
3rd Generation Languages
It is called a procedural language.
Translation is done by compiler / interpreter.
Example: C, C++, FORTRAN, COBOL and BASIC.

BASIC PROGRAM

Example: Program in AVERAGING THREE INTEGERS


PRINT Mengira Purata
Basic to compute
PRINT ---------------------
the average of three PRINT Nilai A = ; 20

numbers. PRINT Nilai B = ; 30


PRINT Nilai C = ; 40
PRINT Purata tiga nombor ialah ;
(20+30+40)/3
END
CATEGORIES OF PROGRAMMING LANGUAGE
3rd Generation Language (Assembly Languages)
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
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:
Create table order
a. Result-oriented where they emphasize on
what instead of how. ( OWNERID INTEGER NOT NULL,
b. It is simpler and easier, so programmers ITEM CHAR (40) NOT NULL);
and non-programmers can use this
language with minimum training. SQL Language
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.
CATEGORIES OF PROGRAMMING LANGUAGE
5th Generation Language
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.
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.
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.
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();
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.
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.
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.


PROGRAMMING PARADIGM
A programming paradigm is a fundamental style of
computer programming.
Programming paradigms differ in how each element
of the programs is represented and how steps are
defined for solving problems.
As the name suggests, Object Oriented
Programming (OOP) focuses on representing
problems using real-world objects and their
behavior, while Structured Programming deals
with organizing the program in a logical structure.
DIFFERENTIATE BETWEEN STRUCTURED AND OBJECT
ORIENTED PROGRAMMING

The focus of Structured Programming is to structure


the program in to a hierarchy of subprograms
The focus of OOP is to break down the programming
task in to objects, which encapsulate data and methods
OOP is considered more flexible than structured
programming, because OOP separates a program into
a network of subsystems rather than structuring the
program in to a hierarchy
Even though structuring provides certain clarity, a
small change to a very large structured program may
cause a ripple effect of having to change multiple
subprograms.
THE END

THANK YOU..

Das könnte Ihnen auch gefallen