L4: Introduction to Computer Science
Engineering department
2024
What is the flow chart
• A flowchart is simply a graphical representation of steps.
• It shows steps in sequential order and is widely used in
presenting the flow of algorithms, workflow or processes.
• Typically, a flowchart shows the steps as boxes of various
kinds, and their order by connecting them with arrows.
When to Draw Flowchart?
• It helps to clarify complex processes.
• It identifies steps, including delays; needless storage and
transportation; unnecessary work, duplication, and added
expense; breakdowns in communication.
• It helps team members gain a shared understanding of the
process and use this knowledge to collect data, identify
problems, focus discussions, and identify resources.
• It serves as a basis for designing new processes.
Flowcharts: symbols to represent
statements
Calculate the area of a rectangle, given the length
(L) and width (w).
If statement
Determine the state of a
student (failed or succeeded)
depending on his/her score in
the exam (full mark is
assumed to be 100).
Example largest number: Compare 3 Numbers
This flowchart shows the design of a program that reads 3 numbers (A,
B, C) and prints the largest.
Example loop: Print Numbers from 1 to 100
Example loop: Print Odd Numbers
from 1 to 100
Example Print Sum of Numbers from 1 to 100
This means: print the sum = 1 + 2 + 3 + 4 + 5 + … + 100
Program design: Use Variable SUM to accumulate summation.
Variable N is used as a counter to hold numbers from 1 to 100.
Variables SUM and N are initialized to 0 and 1, respectively.
Example Calculate Square of Numbers
Print a sequence of numbers and their squares, starting from one to M
where M is an input.
Example Calculate Average Students Score
Read student scores and compute their average. Assume there are 50
students.
Example Calculate the Factorial
Calculate F = M!. M is a value supplied by user when program starts.
This means: F = M! = 1 * 2 * 3 * 4 * 5 * … * (M – 1) * M
Variable N is used as a counter to hold numbers from 1 to M. Variables N
and F are initialized to 1.
Q1 : calculates the length of the third triangle side given the lengths of
the other two sides and the angle between them in degrees.
Q2.Draw a flowchart that prints the even numbers from 106 to 200.
Q3.Draw a flowchart that calculates the multiplication of numbers {1, 2, …, 10}.
Q4.Draw a flowchart that calculates summation of even numbers between 1 and 101.
Q5. Draw a flowchart that takes a student mark then calculates and prints its
equivalence grade {excellent, very good, good, pass, failed}, knowing that the
maximum student mark is 100.
Q6.Draw a flowchart that reads N numbers from a user and prints their maximum and
minimum.
Q7.Draw a flowchart that finds the root of the equation (𝑎𝑥2+ 𝑏𝑥 + 𝑐). The program
should take the values of a, b, c from the user.