Professional Documents
Culture Documents
Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur
Some Terminologies
Algorithm / Flowchart
A stepstep-by by-step procedure for solving a particular problem. Independent of the programming language.
Program
A translation of the algorithm/flowchart into a form that can be processed by a computer. Typically written in a highhigh-level language like C, C++, Java, etc.
Contd.
Memory map
Address N-1
Variables in Memory
Variable X 10 20 21 105
X 20 20 18 18
Y ? 15 15 3
Data Types
Three common data types used:
Integer :: can store only whole numbers
Examples: 25, -56, 1, 0
Float ::
32 bits 64 bits
Char ::
8 bits (ASCII code) 16 bits (UNICODE, used in Java)
Problem solving
Step 1:
Clearly specify the problem to be solved.
Step 2:
Draw flowchart or write algorithm.
Step 3:
Convert flowchart (algorithm) into program code.
Step 4:
Compile the program into object code.
Step 5:
Execute the program.
Computation
Input / Output
Decision Box
Start / Stop
Dept. of CSE, IIT KGP
Contd.
Flow of control
Connector
START
READ A, B, C
S=A+B+C
OUTPUT S
STOP
Dept. of CSE, IIT KGP
READ X, Y
YES
IS X>Y?
NO
OUTPUT X
OUTPUT Y
STOP
STOP
READ X, Y, Z
YES
IS X > Y?
NO
Max = X
Max = Y
YES
OUTPUT Max STOP
Dept. of CSE, IIT KGP
IS Max > Z?
NO
OUTPUT Z STOP
NO
IS COUNT > N?
YES
OUTPUT SUM STOP
Example 5: SUM = 12 + 22 + 32 + N2
START READ N SUM = 0 COUNT = 1 SUM = SUM + COUNT COUNT COUNT = COUNT + 1
NO
IS COUNT > N?
YES
OUTPUT SUM STOP
NO
IS COUNT > N?
YES
OUTPUT SUM STOP
NO
IS COUNT > N?
YES
OUTPUT PROD STOP
NO
IS COUNT > N?
YES
OUTPUT SUM STOP
NO
YES
OUTPUT SUM STOP
ax2 + bx + c = 0
TRY YOURSELF
READ MARKS
MARKS 90?
NO
MARKS 80?
NO
MARKS 70?
NO
YES
OUTPUT Ex
YES
OUTPUT A
YES
OUTPUT B
STOP
STOP
STOP
NO
MARKS 60?
MARKS 50?
NO
MARKS 35?
NO
YES
OUTPUT C
YES
OUTPUT D
YES
OUTPUT P OUTPUT F
STOP
STOP
STOP
STOP