Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Programming

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

Symbol Name Function


Indicates the beginning or end of a
Terminator
program flow in your diagram.
Indicates any processing function
Process

Input/ output operation


Data

A diamond represents a decision .


Decision Indicates a decision point between
two or more paths in a flowchart
Lines represent the flow of the
sequence and direction of a
Arrows
process.
Connection between symbols.

6
Start

Get dressed

Yes Do you have No


money in
your wallet?

Example 1: Put money in your


wallet
Draw a flowchart
for going to market Go to the market
to purchase a pen
Yes Is the brand No
of a pen
available?
Take the pen

Make payment
End 7
Start

Example 2: Draw Input firstNumber

a flowchart of a Input
program that secondNumber

calculate the sum = firstNumber + secondNumber


sum of two
numbers entered Print sum
by a user.
End

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

Example 6: Draw a Input degree


flowchart of a
program that show yes No
up word “pass” if degree >=50

the degree of the


user is greater than Print “Fail”
Print “pass”
or equal to 50 and
print “fail” if the
degree less than
50.
Stop

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

Example 8: Draw yes


x>y
No

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

Yes No Yes Yes


B>C A>B A>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 = “Excellent” Yes No


85> degree >= 75
Yes No
75> degree >= 65
Grade = “very good”

Grade = “Good”

Yes 65> No
degree
>= 50
Grade = “pass”

Grade = “fail”
Print Grade

End 21
Thanks

22

You might also like