Documente Academic
Documente Profesional
Documente Cultură
Contents
Computer Problem Solving
Algorithm and Its Characteristics
Algorithm Writing Techniques
Algorithms for Simple Problems
Programming Techniques
Structured Programming
Functional Design
Object Oriented Design
Jahangir Alam
When problems are solved with the help of
computers following steps are to be performed:
Problem & Requirements Analysis
Problem Partitioning
Algorithm Development
Coding
Testing
In a hexagon
a group of
READ/ steps or sub-
WRITE algorithm can
be indicated
Flow Chart
Continuation
ASSIGNMENT Symbol
Step 1: START
START
Step
2: Get the two READ X, Y
numbers, X,Y
Step 3: TEMP <- X TEMP <- X
X <- Y
Step 4: X <- Y
Y <- TEMP
Step 7: STOP
START
Step 1: START
Step 2: Get the number,
X
READ X
X <- -X
X<0
Step 4: WRITE X N
X <- -X
STOP
Step 1: START
Step 2: Get How Many Numbers, N
Step 3: Initialize I and Flag
Step 4: I <- 0
FLAG <- 0
Step 4: Get Number to be Searched, TARGET
Step 5: Get the next number, X
Step 6: IF (X=TARGET) THEN FLAG=1 : GO TO 9
Step 7: I <- I+1
Step 8: IF I<=N THEN GO TO 5
Step 9: IF (FLAG =1) WRITE FOUND ELSE WRITE NOT FOUND
Step 10: STOP
Step 1: START
Step 2: Get the number, NUM
Step 8: STOP
Step 1: START
Step 2: Get the number, NUM
Step 3: Initialize SUM
SUM <- 0
Step 4: Calculate Remainder
REM <- NUM INT(NUM/10)*10
Step 5: SUM <- SUM + REM
Step 6: NUM <- INT(NUM/10)
Step 7: IF NUM< > 0 THEN GO TO 4
Step 8: WRITE SUM
Step 9: STOP
Step 1: START
Step 2: Get the number and base, NUM,R
Step 7: STOP
Step 1: START
Step 2: Get How Many Numbers, N
Step 3: I <- 1
Step 4: Get Next No, X
Step 5: IF X MOD 3 = 0 THEN WRITE X
Step 6: I <- I+1
Step 7: IF I <= N THEN GO TO 4
Step 8: STOP
Following three conditional operators may be used in Algorithms:
AND
OR
NOT
a b a AND b a b a OR b a NOT a
F F F T F
F F F
F T F F T T
F T
T F F T F T
T T T T T T
Step 1: START
Step 2: Get the Number, X
Step
3: IF X MOD 5 = 0 OR X MOD 11 = 0
THEN WRITE YES ELSE WRITE NO
Step 4: STOP