










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











Example 1: Draw a flowchart to convert the length in feet to centimeter.
Solution:
START
Input Lft
Lcm = Lft x 30
STOP
Print Lcm
Example 2: Draw a flowchart to read the two sides of a rectangle and calculate its area.
Solution:
A = L x W
Example 4: Write an algorithm and draw a flowchart to calculate
Flowchart:
This program can be generalized and solved using the loop as in the following example
Example 5: Write an algorithm and draw a flowchart to calculate 24 using a loop approach? Verify your result by a trace table.
Flowchart:
Product = Base Counter = 1
is Counter < Power
Example 4-1: Draw a flowchart to add two numbers entered by user.
Solution:
Start
Input the two numbers (e.g. A and B)
End
Display Summation (C)
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 = - num
End
Display num
Example 4-4: Draw a flowchart to read a number and identify either the number is positive or negative.
Solution:
Start
Read N
End
Is N< Yes No
Write “Negative number”
Write “Positive number”
Example 4-5: Draw a flowchart to find all the roots of a quadratic equation ax^2 +bx+c=0.
Solution:
Start
Input the variables a,b,c
Calculate the discriminant D=b^2 - 4a*c
End
Is D ≥ 0
root1=(-b+ √D )/(2a) root2=(-b- √D )/(2a)
real=(-b)/(2a) imag=( √ -D)/(2a)
root1=real+jimag root2=real-jimag
print root1, root
Example 4-7: Draw a flowchart to obtain to obtain the factorial of
Solution:
Start
Mul = Mul * Index
End
Is Index > 1?
Decrease Index by 1
Yes
No
Mul = 1 Index = 20
Display Mul
Example 4-8: Draw a flowchart to add even numbers from 0 to 20
Solution :
Start
End
Is Count>
Yes
No
Is Count even
Sum=Sum+Count
Count=Count+
No Yes
Sum=
Count=
Print Sum
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:
Start Input N K= 1
Input Name, M1, M2, M
Average = (M1 + M2 + M3)/
Fail Average < 50
Pass Average < 65
Good Average < 75
Very Good Average < 85
Excellent Print Name, average, grade
K > N Stop
Yes
No Yes No Yes No Yes No
No Yes
K=K+