Professional Documents
Culture Documents
Compute Assign Increment Decrement Get Display: Count Initialval Lastval
Compute Assign Increment Decrement Get Display: Count Initialval Lastval
Worksheet 1(Algorithms)
Objectives
To understand the concept of algorithm
To understand basic steps of algorithm design
To work with the basic algorithm constructs using pseudocode and flowchart
I. Basic Algorithm Concept
An algorithm, is defined as a well-ordered collection of unambiguous and effectively
computable operations, that when executed, produces a result and halts in a finite amount of
time.
II. Basic Algorithm Constructs
All algorithms are constructed using three control structure or construct. These are:-
The sequence structure is the construct where one statement is executed after another
The selection structure is the construct where statements can executed or skipped
depending on whether a condition evaluates to TRUE or FALSE
The repetition structure is the construct where statements can be executed repeatedly
until a condition evaluates to TRUE or FALSE
A. Pseduocode Construct
Class Constructs
Compute var1 as the sum of x and y or var1<- x + y
Computation/Assignmen
Assign x2 + y to var2 or var2 <-x2 + y
t
Increment counter1 or counter1<-counter1 + 1
Decrement counter1 or counter1<-counter1 - 1
Input: Get var1, var2, …
Input/Output
Output: Display var1, var2, …
B. Flow Chart
Symbol Name/meaning Symbol Name/meaning
Process – Any type of internal Connector – connects sections of
operation: data transformation, data the flowchart, so that the diagram
movement, logic operation, etc can maintain a smooth, linear flow
Input/Output – input or output of Terminal – indicates start or end of
Data the program or algorithm
Decision – evaluates a condition or Flow lines – arrows that indicate
statement and branches depending the direction of the progression of
1|Page
Adama Science & Technology University
School of Electrical Enginering & Computing
Computer Science & Engineering Program
2|Page
Adama Science & Technology University
School of Electrical Enginering & Computing
Computer Science & Engineering Program
13. Write an algorithm that implement a simple calculator that performs the basic operations ( +,
-,* and /). Your algorithm should properly handle division by zero (Flowchart)
3|Page