0% found this document useful (0 votes)
314 views

Flowcharting Examples: Example 1: Draw A Flowchart To Convert The Length in Feet To

The document provides 11 examples of flowcharts with solutions. The examples cover a range of problems including converting between units, calculating areas and sums, determining largest/smallest values, and evaluating conditional logic. For each example, the problem statement is given followed by the corresponding flowchart solution. The flowcharts use standard symbols and notation to visually depict the step-by-step logic and data flow for solving each problem algorithmically.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
314 views

Flowcharting Examples: Example 1: Draw A Flowchart To Convert The Length in Feet To

The document provides 11 examples of flowcharts with solutions. The examples cover a range of problems including converting between units, calculating areas and sums, determining largest/smallest values, and evaluating conditional logic. For each example, the problem statement is given followed by the corresponding flowchart solution. The flowcharts use standard symbols and notation to visually depict the step-by-step logic and data flow for solving each problem algorithmically.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Flowcharting Examples

Flowcharting Examples

Example 1: Draw a flowchart to convert the length in feet to


centimeter.

Solution:

START

Input Lft

Lcm = Lft x 30

Print Lcm

STOP

1
Flowcharting Examples

Example 2: Draw a flowchart to read the two sides of a rectangle


and calculate its area.

Solution:

START

Input
W, L

A=LxW

Print
A

STOP

2
Flowcharting Examples

Example 3: Draw a flowchart to reads two values, determines the


largest value and prints the largest value with an identifying
message.

Solution:

START

Input
VALUE1, VALUE2

Yes No
Value1 >
Value

MAX = VALUE1 MAX = VALUE2

Print
“The largest value is”,
MAX

STOP

3
Flowcharting Examples

Example 4: Write an algorithm and draw a flowchart to calculate


24 .

Flowchart:

START

Base=2

Product = Base

Product = Product * Base

Product = Product * Base

Product = Product * Base

Print Product

STOP

This program can be generalized and solved using the loop as in the
following example

4
Flowcharting Examples

Example 5: Write an algorithm and draw a flowchart to calculate


24 using a loop approach? Verify your result by a trace table.

Flowchart:

START

Base =2
Power =4

Product = Base
Counter = 1

is N
Counter < Power

Y Print
Product = Product * Base
Product

Counter = Counter + 1 STOP

5
Flowcharting Examples

Trace table:-

6
Flowcharting Examples

Example 4-1: Draw a flowchart to add two numbers entered by


user.

Solution:

Start

Input the two


numbers (e.g. A
and B)

C=A+B

Display
Summation (C)

End

7
Flowcharting Examples

Example 4-2: Draw a flowchart to read a variable num1 = 7 and


store the negative value of num1 in another variable num2.

Solution:

Start

Data input
(num1 = 7)

num2 = - num1

Display num2

End

8
Flowcharting Examples

Example 4-3: Draw a flowchart to compute the area of a circle of


Radius R.

Solution:

9
Flowcharting Examples

Example 4-4: Draw a flowchart to read a number and identify


either the number is positive or negative.

Solution:

Start

Read N

Yes No
Is N<0

Write “Negative Write “Positive


number” number”

End

10
Flowcharting Examples

Example 4-5: Draw a flowchart to find all the roots of a quadratic


equation ax2+bx+c=0.

Solution:

Start

Input the
variables a,b,c

Calculate the discriminant


D=b^2 - 4a*c

Is
D≥ 0

real=(-b)/(2*a) root1=(-b+√D)/(2*a)
imag=(√-D)/(2*a) root2=(-b-√D)/(2*a)

root1=real+j*imag
root2=real-j*imag

print
root1, root2

End

11
Flowcharting Examples

Example 4-6: Draw a flowchart to obtain the sine of angles from 0


to 360o with a step of 10o.

Solution:

Start

Angle = 0 Deg.

Convert Angle to Radian


Compute the sine of Angle

Display the
Increase Angle
Angle sine
by 10 Deg.

Yes
Is Angle< 360?

No

End

12
Flowcharting Examples

Example 4-7: Draw a flowchart to obtain to obtain the factorial of


20.

Solution:

Start

Mul = 1
Index = 20

Mul = Mul * Index


Decrease Index
by 1

Yes
Is Index>1?

No

Display Mul

End

13
Flowcharting Examples

Example 4-8: Draw a flowchart to add even numbers from 0 to 20

Solution:

Start

Sum=0

Count=1

No Is Count Yes
even

Sum=Sum+Count

Count=Count+1

No
Is Count>20

Yes

Print Sum

End

14
Flowcharting Examples

Example 4-9: Draw a flowchart to find the largest number in a list


of numbers.

Solution:

Start

Read a=[ a(1), a(2), .., a(n) ]

i=1

Largest=a(1)

i=i+1

Yes
Is i>n

No Print
Largest

Yes Is a(i) >


Largest
End
Largest=a(i) No

15
Flowcharting Examples

Example 4-10: Draw a flowchart to enter the name of N students


and three marks for each student and print the student name,
average mark, and grade.

Mark Grade
<= 85 Excellent
<=75>85 Very Good
<=65>75 Good
<=50>65 Pass
>50 Fail

Solution:

16
Flowcharting Examples

Start

Input N

K= 1

Input Name, M1, M2,


M3

Average = (M1 + M2 + M3)/3

Yes
Fail Average< 50

No

Yes
Pass Average< 65

No

Yes
Good Average< 75

No

Yes
Very Good Average< 85

No

Excellent

Print Name, average,


grade

K=K+1

No
K > N

Yes

Stop

17
Flowcharting Examples

Example 4-11: Draw a flowchart to accepts N numbers and get the


summation of negative, the summation of positive numbers and the
number in each group.

Flowchart:

Start

Input N

K=1
Jn=0 &Jp=0
Sumn=0 &Sump=0

Input Num

Yes No
Num< 0

Jn = Jn + 1 Jp = Jp + 1
Sumn = Sumn + Num Sump = Sump + Num

K = K+1

No
K>N

Yes

Print Name, average,


grade

Stop

18

You might also like