Вы находитесь на странице: 1из 10

PROGRAMMING

PROGRAM
IMPLEMENTATION task of writing and
modifying instructions
for the computer to
carry out
SECTION THREE
2
1

PROGRAM Summation
VAR
First, Last, Sum,
Temp: integer:
PROGRAMMING LANGUAGES
BEGIN
writeln(Type the first number);
Readln First;
FIRST GENERATION
writeln(Type the last number);
Readln Last;
sum:=0;
SECOND GENERATION (2GL)
IF First > last THEN
BEGIN THIRD GENERATION (3GL)
Temp:= Last;
Last:= First;
First:= Temp; FOURTH GENERATION (4GL)
END
While (Last>First) DO
BEGIN
FIFTH GENERATION (5GL)
Sum := Sum + First;
First:= First + 1;
END
Writeln(The sum is ,Sum);
3
END.
4

MACHINE CODE/
LANGUAGE
FIRST GENERATION A combination of 0s and 1s
that form the instructions for
the Control Unit of the CPU.
MACHINE CODE/ These 0s and 1s are seen as
LANGUAGE electrical signals (off and on).
Low-level Language only
understood by the computer.

5 6

1
ASSEMBLY LANGUAGE
SECOND GENERATION A program which uses symbols to
represent machine instructions.
For example
ASSEMBLY LANGUAGE LDN 25 means
to put the value 25 in the register
(memory) of the CPU.

7 8

START 10 (Start the program storage at location 10)


LDN 0
STA 27 (set the contents of location 27 to zero)
ASSEMBLER
LDN 30
STA 26 (set the contents of location 26 to 30)
LDA@26 (loading the content of location 26) a program which converts
A: JAZ B
ADD 27
(checking for a condition to end procedure A)
(adding a value to content of location 27)
Assembly Language to
STA 27 (storing the new value in location 27) Machine Language in
LDN 1 (increasing the content of location 26 by 1)
ADD 26 order for the computer to
STA 26
LDA@26
carry out the instructions
JPU A (jump to load next number) given
B: STOP
.END (brings an end to the program)

9 10

THIRD GENERATION
LANGUAGE ALGORITHMN

HIGH LEVEL LANGUAGES a sequence of steps for


getting a task done
a program which is made up of
English-like instructions which
are placed in detailed steps
(eg) Pascal, Fortran, Cobol, C,
C+, C++, Ada, Basic

12

11

2
Grade Assignment Algorithm
1. Read Homework, Tests, and Exam. SOURCE CODE

2. Calculate  thetext of a program


Average = 0.2 * Homework +
0.5 * Tests +
written in high level
0.3 * Exam language
3. If Average 60 then
Set Grade = P
Else  Also
known as
Set Grade = F PSEUDOCODE
4. Display Average and Grade.
13 14

PROGRAM Grade Assignment(input, output)

VAR
COMPILER
homework, tests, exam,
Average: real;
Grade: char; a program which changes
BEGIN
write(Enter homework, test and exam scores); the source code of high-
high-
readln(homework, tests, exam);
Average:=0.2*homework+0.5*tests+0.3*exams; level language to
IF Average >= 60 THEN
Grade := P
machine code so that the
ELSE
Grade := F;
computer can understand
writeln(Average = ,Average:5:1, Grade= ,Grade) it and execute it
END.

15 16

FOURTH GENERATION FIFTH GENERATION


LANGUAGE LANGUAGE
allows you to specify what you want Produces graphical tools for the
instead of the steps needed to do it. Used creation of bodies of programming
for querying databases. code.
(eg) FIND ALL RECORDS WHERE
Also known as Object-Oriented
NAME IS "SMITH"
Programming
(eg) RPGL Report Generator
Language (eg) Java
SQL Standard Query Language

17 18

3
READ
PROGRAMMING
STATEMENTS This statement allows users
to enter data into the
computer or the program to
accept data from users
(eg) read
readln
19 20

WRITE IF -THEN

This statement allows This statement allows the


information to be displayed computer to perform a specific
action if a given condition is TRUE.
on the monitor. It gives the
output of the program.
(eg) IF hours > 40 THEN
(eg) write (condition)
writeln overtime:= hours 40
(action)
21 22

IF THEN ELSE IF Average >= 90 THEN


Grade := A

This statement allows the ELSE IF Average >= 80 THEN


computer to perform a Grade:= B
ELSE IF Average >= 70 THEN
specific action for the first Grade:= C
condition it finds to be ELSE IF Average >= 60 THEN
TRUE. Grade:= D
ELSE
Grade:=F

24
23

4
FOR LOOP
REPEATING STATEMENTS
These statements instruct the computer Instructs the computer to
to repeat specific actions while a repeat an action for a certain
condition is TRUE.
number of times.
The computer stops performing the
actions once the condition becomes (eg) FOR i:=1 TO 10 DO
FALSE.
These statements are also known as
writeln i:
LOOPS
(eg) FOR and WHILE statements 25
26

WHILE LOOP LOGICAL OPERATORS


Instructs the computer to keep > greater than
on repeating an action once the < less than
condition is TRUE until the >= greater than or equal to
condition becomes FALSE. <= less than or equal to
<> not equal to
(eg) number := 10:
= equal to
WHILE number > 0 DO
number:= number -1;
27 28

MATHEMATICAL
DATA TYPES
OPERATORS
- SUBTRACT Variables can be
+ ADDITION INTEGER (eg) 2, 23, 11
* MULTIPLICATION REAL real number (eg) 3.75
/ DIVISION CHAR character (eg) A, B
^ POWER BOOLEAN true or false
STRING group of text (eg)
williams

29 30

5
LOADING
PROGRAMMING The movement of a program
from disk to the computers
TERMS main memory.

31 32

OBJECT CODE
The code produced by a
SOURCE OBJECT
compiler from the source code, CODE COMPILER
CODE
usually in the form of machine
language that a computer can
execute directly, or sometimes
in assembly language.

33 34

EXECUTING INTERPRETING
The carrying out of the A program which converts a program
written in a high-level language to
instructions of a program by
machine language.
the computers CPU As each instruction is encountered, it
is converted to machine code and
executed at the same time.

35 36

6
COMPILING DRY RUN
A program which converts a program To execute a program by hand,
written in a high-level language to writing values of
machine language. variables and other data results on
The entire program is first paper, in order to check its operation
converted to machine code, then this or to track down a bug( an error
code is executed. found in the program).

37 38

DEBUGGING SYNTAX ERRORS


Finding the causes for the errors in a Errors in a program caused
program and removing those errors
by the programmer not
so that the program can be executed
without errors. knowing how to write the
programming rules of the
programming language

39 40

LOGIC ERRORS RUN-TIME ERRORS


Errors in a program caused by errors that occur during the
execution of a program especially in
the programmer not properly
relation to the running out of memory
thinking out the solution of which some times is the result of a
the problem. non ending loop.

41

7
A TRACE TABLE is a table of
values given to variables of a
TRACE TABLES
program where the changes on
each value is shown for each
line of the program code.

43 44

PROGRAM Summation
VAR
First, Last, Sum,
Temp: integer:

BEGIN
writeln(Type the first number);
Readln First;
writeln(Type the last number);
First, Last, Sum,
Readln Last;
sum:=0;
IF First > last THEN Temp: integer:
BEGIN
Temp:= Last;
Last:= First;
First:= Temp;
END
While (Last>First) DO
BEGIN
Sum := Sum + First;
First:= First + 1;
END
Writeln(The sum is ,Sum);
45 46
END.

PROGRAM Summation
VAR
First, Last, Sum,
Temp: integer:

BEGIN
First Last Sum Temp writeln(Type the first number);
Readln First;
writeln(Type the last number);
Readln Last;
sum:=0;
IF First > last THEN
BEGIN
Temp:= Last;
Last:= First;
First:= Temp;
END
While (Last>First) DO
BEGIN
Sum := Sum + First;
First:= First + 1;
END
Writeln(The sum is ,Sum);
48
47 END.

8
writeln(Type the first number); First Last Sum Temp
Readln First; 10 5 0
writeln(Type the last number);
Readln Last;
sum:=0;

49
50

PROGRAM Summation
VAR
First, Last, Sum,
Temp: integer:

BEGIN
writeln(Type the first number); IF First > last THEN
Readln First;
writeln(Type the last number); BEGIN
Readln Last;
sum:=0;
IF First > last THEN
Temp:= Last;
BEGIN
Temp:= Last;
Last:= First;
Last:= First;
First:= Temp;
First:= Temp;
END
While (Last>First) DO
BEGIN
Sum := Sum + First;
First:= First + 1;
END
Writeln(The sum is ,Sum);
51 52
END.

PROGRAM Summation
VAR
First, Last, Sum,
Temp: integer:

BEGIN
First Last Sum Temp writeln(Type the first number);
Readln First;
writeln(Type the last number);
10 5 0 Readln Last;
sum:=0;
IF First > last THEN
BEGIN
Temp:= Last;
Last:= First;
5 10 0 5 END
First:= Temp;

While (Last>First) DO
BEGIN
Sum := Sum + First;
First:= First + 1;
END
Writeln(The sum is ,Sum);
54
53 END.

9
First Last Sum Temp
10 5 0
While (Last>First) DO
5 10 0 5
BEGIN 6 10 5 5
Sum := Sum + First; 7 10 11 5
First:= First + 1; 8 10 18 5
END 9 10 26 5
10 10 35 5
55 11 10 45 5 56

PROGRAM Summation
VAR
First, Last, Sum,
Temp: integer:

BEGIN
writeln(Type the first number);
Readln First;
writeln(Type the last number);
Readln Last;
sum:=0;
IF First > last THEN
BEGIN
Temp:= Last;
Last:= First;
First:= Temp;
END
While (Last>First) DO
BEGIN
Sum := Sum + First;
First:= First + 1;
END
Writeln(The sum is ,Sum);
57
END.

10

Вам также может понравиться