Lec 2 Flowcharts and Computer System
Lec 2 Flowcharts and Computer System
Computational
thinking
Dr. Doaa El-Shahat
Computer Science,
Zagazig university, Egypt
Computer system
Lecture 2
Algorithm representation
(Flowcharts)
LECTURE OBJECTIVES
❑ Flowcharts
❑ Standard flowchart symbols
❑ Rules for drawing flowcharts
❑ Computer system: hardware and software
❑ Data representation: ASCII and Unicode
Flowcharts
❑ Flowchart is basically a pictorial or
diagrammatic representation of an algorithm
using standard symbols.
❑ It is a graphical representation that explains
the sequence of operations to be performed in
order to solve a problem under consideration.
Standard flowchart symbols
❑ Various standard symbols are used to express different
operations in the flowchart.
Stop
Start
Calculation of simple interest
Read P,T and Rtwo
Algorithm : Calculation of Simple Interest
Step 1: Start I = P*T*R/100
Step 2: Read principle (P), time (T) and rate (R)
Step 3: Calculate I = P*T*R/100
Print I
Step 4: Print I as Interest
Step 5: Stop
Stop
• Algorithm for find
the greater number
between two
numbers.
Step 1: Start
Step 2: Read A and B
Step 3: if A>B then Print A
Step 4: Otherwise, print B
Step 5: Stop
Start
Volume of a sphere
Read rtwo
Step 1: Start
Step 2: Read r v = (4/3) * pi * r3
Step 3: Calculate v = (4/3) * pi * r3 .
Step 4: Print v Print v
Step 5: Stop
Stop
Write an algorithm to find the factorial
of a number N.
Step 1: Start
Step 2: Read N
Step 3: Initialize F=1, i=1
Step 4: F = F * i
Step 5: increment i by 1
Step 6: Repeat step 4 and step 5 until i=N
Step 7: print F
Step 8: Stop
Write an algorithm to find sum of the
integers
from 1 to 100.
Step 1: Start
Step 2: Initialize count=1, sum=0
Step 3: sum = sum + i
Step 4: increment i by 1
Step 5: Repeat step 3 and step 4 until i>100
Step 6: print sum
Step 7: Stop
Difference between algorithm, flowchart and
program
Note
▪ An algorithm is not a computer program.
▪ A computer program is an implementation of an
algorithm.
Computer system
Hardware software
Hardware
7
2 = 128
s 115 01110011 M 077 01001101
Letter ASCII Code Binary
t 116 01110100 N 078 01001110
a 097 01100001 u 117 01110101 O 079 01001111
b 098 01100010 v 118 01110110 P 080 01010000
c 099 01100011 w 119 01110111 Q 081 01010001
d 100 01100100 x 120 01111000 R 082 01010010
e 101 01100101 y 121 01111001 S 083 01010011
f 102 01100110 z 122 01111010 T 084 01010100
g 103 01100111 A 065 01000001 U 085 01010101
h 104 01101000 B 066 01000010 V 086 01010110
i 105 01101001 C 067 01000011 W 087 01010111
j 106 01101010 D 068 01000100 X 088 01011000
k 107 01101011 E 069 01000101 Y 089 01011001
l 108 01101100 F 070 01000110 Z 090 01011010
m 109 01101101
G 071 01000111
n 110 01101110
H 072 01001000
o 111 01101111
I 073 01001001
p 112 01110000
J 074 01001010
q 113 01110001
K 075 01001011
r 114 01110010
L 076 01001100
Unicode, why?
▪ With a 32-bit Unicode, we can represent 232
characters in the computer memory.
▪ Before Unicode was invented, the character encodings
were limited and could not contain enough characters
to cover all the world’s languages.
▪ Unicode has been adopted by all modern software.
Data representation
▪ Computers store data or information in the form of "1" and
"0"s in different types of storages such as memory, hard disk,
USB drives etc.
▪ Data Units
Bit • The smallest unit of data in a computer.
• A bit is a binary digit-either a 1 or 0.
Byte A byte is a combination of eight bits.
word Two bytes or sixteen bits
Kilo Byte 1024 bytes or 1024x8 bits (1 KB).
Mega Byte 1024 Kilo Bytes (1 MB).
Giga Byte 1024 Mega Bytes (1 GB).
Tera Byte 1024 Giga Bytes (1 TB).
Peta Byte 1024 Tera Bytes (1 PB).