Icte 7
Icte 7
Chapter (7)
Computer Programming
Computer Programming
Objectives
Programming: البرمجة هي عملية كتابة أوامر للحاسب تخبر المعالج بما يجب أن
يقوم به
• The Process of providing instructions to the computer that tells
the processor what to do.
Algorithms and Programs
الخوارزمي يقدم حال لمشكلة دون االعتماد على أي لغة للبرمجة بينما
البرنامج عبارة عن خوارزمي مكتوب بلغة معينة
• An Algorithm is a solution to a problem that is
independent of any programming language.
While
• A program is an algorithm expressed using a
specific set of instructions from any
programming language.
Algorithm Example
- Machine language
- Assembly languages
- High-level languages
6
Machine Language
• Programs and memory locations are written
in strings of 0s and 1s.
• Problems with machine languages
– Programs are difficult to write and debug
• Only option available to early programmers.
7
Assembly Language
– For example, A for add, C for compare, etc.
– Use names rather than binary addresses for
memory locations
• Require an assembler to translate the program
into machine language.
8
High-Level Languages
• Transformed programming
– Programs could be written and debugged
much more quickly
• Requires a compiler to convert the
statements into machine language
– Each computer has its own version of a
compiler for each language.
9
Major Programming Languages
• FORTRAN
• COBOL
• BASIC
• Visual Basic
• C/C++
• Java
10
Flowcharts
Flowcharts
Flowchart
Flowchart
– It is a graphical representation of an algorithm.
– Components:
• Arrows/lines: Flow of control
• Diamond: Decision.
12
Flowcharts
Flowchart Notations
Arrows
Diamond
Parallelogram
Oval
Rectangle
13
Flowcharts
Examples
Flowcharts
START
READ
A,B
Sum = A+B
PRINT
Sum
Stop
15
Flowcharts
START
READ
A,B,C
Sum= A+B+C
Average = (A+B+C) / 3
Avg = Sum / 3
PRINT
Average
Stop
16
Flowcharts
READ
R
Area = 3.14 * R * R
PRINT
Area
Stop
17
Flowcharts
START
READ
N1, N2
Stop
19
Flowcharts
START
READ
D
Stop
20
Flowcharts
READ
D
Stop
21