Programming Section 01
Programming Section 01
Section - 1
What is a flowchart?
• D1. A flowchart is a diagrammatic representation that illustrates the
sequence of operations to be performed to get the solution of a
problem.
• D2. 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.
3
Using a flowchart has a variety of benefits:
• Flowchart facilitates communication between programmers and
businesspeople.
• Once the flowchart is drawn, it becomes easy to write the program in
any high-level language.
• Flowchart is helpful in understanding the logic of a complicated
problem.
4
Flowchart • Various flowchart shapes correspond to
various conventional meanings. The
Symbols following are some of the more popular
shapes' meanings:
5
Flowchart Symbols
6
Start
Get dressed
Make payment
End 7
Start
a flowchart of a Input
program that secondNumber
8
Start
Input w, h
Example 3:
Draw a flowchart
of a program to Area = w * h
calculate the
area of a
Rectangle? Output Area
End
9
Start
Example 4: Input x
Draw a flowchart
to convert the Z = x * 100
length in meter
to centimeter. Print z
End
10
Start
Input n1, n2
Example 5: Draw
a flowchart for s = n1 + n2
finding the
average of two Av = s/2
numbers.
Print Av
End
11
Start
12
Start
Input x, y
Example 7:
Draw a flowchart of No Yes
y=0?
a program that
calculates the
division of two Z = x/ y
numbers . If the
divisor equals to Print Z Print “undefined”
zero display
“undefined”. Stop
13
Start
Input x, y
a flowchart of a
program that
Max = x Max = y
read two values
and print the
largest value. Print Max
Stop
14
Example 9: Draw a flowchart of a program to
find the largest of three numbers A & B & c.
Start
Input A, B, C
Max = B Max = A
Max = C
Print Max
15
Stop
Example 10:
Draw a flowchart to calculate the area of a triangle with
three sides a, b, c which are given by the user.
The area = 𝑠 ∗ 𝑠 − 𝑎 ∗ 𝑠 − 𝑏 ∗ (𝑠 − 𝑐)
𝑎+𝑏+𝑐
where s is the semi-perimeter of triangle s = .
2
And calculate the perimeter of the triangle P = a+b+c.
16
Example 10:
Start
Input a, b,c
S = (a + b + c) / 2
A = 𝑠 ∗ 𝑠 − 𝑎 ∗ 𝑠 − 𝑏 ∗ (𝑠 − 𝑐)
P = s *2
Print A, P
End
17
Start
Input n1
NO Yes
n1 % 3 =0
Example 11: Draw a
Print “divisible by
flowchart to find out Print “not divisible
by 3” 3”
if a number is
divisible by 3.
End
18
Start
Input x
NO Yes
x % 2 =0
Example 12:
Draw a flowchart to Print x + “is odd” Print x + “is Even”
determine if a number
is even or odd.
End
19
Example 13: Draw a flowchart
to print the grade of a
student. The user must enter
the student’s degree.
20
Start
Input degree
Yes No
100>=degree >= 85
Grade = “Good”
Yes 65> No
degree
>= 50
Grade = “pass”
Grade = “fail”
Print Grade
End 21
Thanks
22