Solved Assignment Problems Algorithms and Flowcharts
Solved Assignment Problems Algorithms and Flowcharts
Algorithm
An algorithm is defined as sequence of steps to solve a problem (task). The steps must be finite, well defined
and unambiguous. Writing algorithm requires some thinking. Algorithm can also be defined as a plan to solve a
problem and represents its logic. Note that an algorithm is of no use if it does not help us arrive at the desired
solution
Algorithm characteristics
1. It should have finite number of steps. No one can be expected to execute infinite number of steps.
2. The steps must be in order and simple
3. Each step should be defined clearly i.e. without un-ambiguity (without doubtfulness)
4. Must include all required information
5. Should exhibit at least one output
Flowchart
A flowchart is a pictorial (graphical) representation of an algorithm. A flowchart is drawn using different
kinds of symbols. A symbol is used for a specific purpose. Each symbol has name.
Different algorithms have different performance characteristics to solve the same problem. Some
algorithms are fast. Some are slow. Some occupy more memory space. Some occupy less memory
space. Some are complex and some algorithms are simple.
Algorithm Flowchart
1. Start Start
2. Read r
3. vol = (4/3) *pi*r*r*r
4. Print or display vol
5. Stop Read r
Write vol
Stop
Q2. Write a program the converts the input Celsius degree into its equivalent Fahrenheit degree. Use
the formula: F = (9/5) *C+32.
Algorithm Flowchart
1. Start Start
2. Initialize F=0, C=0
3. Read C
4. Fh = (1.8*C) + 32
C=0, F=0
5. Print or display Fh
6. Stop
Read C
Fh = (1.8*C) + 32
Write Fh
Stop
Algorithm Flowchart
1. Start
2. Read dollar Start
3. peso = dollar * 51.50
4. Print or display peso
5. Stop Read dollar
Write peso
Stop
Q4. Write a program that converts an input inch(es) into its equivalent centimeters. Take note that one
inch is equivalent to 2.54cms
Algorithm Flowchart
1. Start Start
2. Read inch
3. cm = 2.54 * inch
4. Print or display cm
Read inch
5. Stop
Write cm
Stop
Algorithm Flowchart
1. Start
2. Read x, y Start
3. Declare third variable, z
z=x
x=y Read x, y
y=z
4. Print or display x, y
5. Stop z=x
x=y
y=z
Write x, y
Stop
Q6. Design a program to find the circumference of a circle. Use the formula: C=2πr, where π is
approximately equivalent 3.1416.
Algorithm Flowchart
1. Start
2. Read r Start
3. Calculate circumference by
the equation:
Circum = 2*pi*r Read r
4. Print Circum
5. Stop
Circum = 2*pi*r
Write
Circum
Stop
Algorithm Flowchart
1. Start
2. Read P Start
3. Read S
4. Read Y
5. D = (P-S) * Y Read P
6. Print or display D
7. Stop
Read S
Read Y
D = (P-S) * Y
Write D
Stop
Algorithm Flowchart
1. Start
2. Read x and y Start
3. x = x + y
y=x-y
x=x-y Read x, y
4. Print or display x, y
5. Stop
x=x+y
y=x-y
x=x-y
Write x, y
Stop
Algorithm Flowchart
1. Start
2. Read R Start
3. Read S
4. Read I
5. EOQ = (2*R*S)/I Read R
6. Print EOQ
7. Stop
Read S
Read I
EOQ = (2*R*S)/I
Write EOQ
Stop
Algorithm Flowchart
1. Start Start
2. Read R, S, I
3. EOQ = (2*R*S)/I
4. Print EOQ Read R, S, I
5. Stop
EOQ = (2*R*S)/I
Write EOQ
Stop
Algorithm Flowchart
1. Start
2. Read r Start
3. Calculate radius by
the equation:
r = sqrt(A/pi) Read A
4. Write r
5. Stop
r = sqrt(A/pi)
Write r
Stop