Exercise of Flowcharts
Draw a flowchart that calculatesthe sum
Practical 1)
and product of two numbers.
Flowchart:
Start
Input numbers x, y
sum =X + y
prod = x*y
Dry run:
Supposed lnput:
Print "Sum is ",sum x=6and y=8
Print "Product is =", prod Process:
sum =6+8
prod = 6*8
Output:
End Sum is =14
Productis =48
Note:
Inputstatement is used togetdata from a user and store in computer memory.
Print statement is used to display data and its respective message. Forexample, In the above
flowchart,
Print "Sum is =", sum
Message Data stored in
memory with name
Sum
Flow Charts
Practical Notebook Computer Science
Draw a flowchart that calculatesthe
Practical 2
difference and division of two numbers.
Flowchart:
Start
Input numbers x, y
diff =x-y
div = x/y
Print "Difference is =", diff
Print "Division is =", div
End
Dry run:
Supposed Input:
x=16 andy=8
Process:
diff = 16-8
div = 16/8
Output:
Difference is =8
Divisionis =2
Practical Notebook Computer Science 9
Draw a flowchart that calculates the cube
Practical 6
of a number.
Flowchart:
Start
Input number x
cube = x*x*x
Print "Cube is =", cube
End
8 Flow Charts
Practical Notebook Computer Science 9
Draw a flowchart that calculates the area
Practical 7)
and perimeter of a rectangle.
Flowchart:
Start
Input numbers I, w
area= |*w
perimeter = 2*l+w)
Print "Area is =,area
Print "Perimeter is =", perimeter
End
Flow Charts 9
Practical Notebook Computer Science 9
Draw a flowchart that calculates the area
Practical9
and circumference of a circle.
Flowchart:
Start
Input number r
area = (22/ *r *r 7)
cf = 2* (22/7) *r
Print "Area is =", area
Print "Circumference is =", cf
End
Flow Charts 10
Practical Notebook Computer Science 9
Draw a flowchart that calculates the area
Practical 10) and perimeter of a square when one side is
given.
Flowchart:
Start
Input number length
area = length * length
p=4*length
Print "Area is =,area
Print "Perimeter is =". p
End
12 Flow Charts
Practical Notebook Computer Science9
Draw a flowchart that converts the
Practical 14) temperature from centigrade to
fahrenheit.
Flowchart:
Start
Input number c
f= (c*9/5) + 32
Print "Temperaturein Fahrenheit is =", f
End
16 Flow Charts
Practical Notebook Computer Science 9
Draw a flowchart that converts the
Practical 16) temperature from fahrenheit to
centigrade.
Flowchart:
Start
Input number
f
C= (f- 32) *5/9
Print "Temperature in centigrade is =",c
End
18 Flow Charts
Practical Notebook Computer Science9
Draw a flowchart that takes a number as
(Practical 18 input and displays whether it is even or
odd.
Flowchart:
Start
Input number n
rem = n mod 2
True rem is 1
False
Print "odd" End Print "even"
Dry run:
Supposed input
n=5
Process:
rem =5mod2
Output:
Odd
Practical Notebook Computer Science 9
Draw a flowchart that takes three numbers
Practical 20) as input and displays the largest among
them.
Flowchart:
Start
Input numbers a, b, c
True
Ka> band a> c False
True False
Print "a is greatest" b> a and b> c
Print "b is greatest"
Print "c is greatest"
End
Note:
In the expression "a> band a>cwe check both "a > b'and "a > c separately. Their results
(true or false) arecombined in away that if both give"true", we get overall true", otherwisewe
get "false".
22 Flow Charts
Practical Notebook Computer Science 9
Draw a flowchart that takes three numbers
(Practical 22)
as input and displays the smallest among
them.
Flowchart:
Start
Input numbers a, b, c
True False
a <band a < c
Print "a is smallest"
True
b<a and b <c False
Print "b is smallest"
Print "c is smallest"
End
Note:
Studentsareadvisedto check the aboveflowchart by assuming different sets ofvalues fora, b and c.
24 Flow Charts
Practical Notebook Computer Science 9
Practical 26) Draw a flowchart that prints the grade of a
student.
Flowchart:
Start
Input number x
Print "A" True
X>=80 False
True False
Print "B" X>= 70
True False
Print "C" X >= 60
True
Print "D" X>=50
False
End Print "D"
28 Flow Charts
Process: 2<10 or2 = 10(true) Process:
x=1 Output: x=10+1= 11
Decision: 2 Decision:
1<10or1 = 10(true)Process: Process: 10<11 or10=11(false)
Output: x=2+1=3 x=9+1= 10 End
1 Decision: Decision:
Process: 3<10or3 =10(true) 10<10 or 10 =10 (true)
x=1+1=2 Output: Output:
Decision: 3 10
Note:
Loop means repetition of steps and we continue repeating until some condition becomes
"False".For example, here "x<= 10' is the condition forthe loop.
Dry
Process: 4< 10 or4- 10(true) Process:
x=2 Output: x=10 +2 = 12
Decision: 4 Decision:
2<10or2= 10 (true) Process: Process: 10<12 or 10-12(false)
Output: x=4+2=6 x=8+2= 10 End
2 Decision: Decision:
Process: 6<10 or6= 10 (true) 10< 10 or 10= 10(true)
x=2 +2=4 Output: Output:
Decision: 6 10
Practical Notebook Computer Science 9
Draw a flowchart that prints integers from
Practical 33)
10 to 1(reverseorder,using loop).
Flowchart:
Start
X= 10
Print x True X>=1 False End
X= X-1
Flow Charts 35
Practical Notebook ComputerScience9
EXCEPTIONAL EXERCISES
Question 1: Draw a flowchart which takes an input and tells whether it's a Mersenne prime or
not, a Mersenne prime is a prime number that is one less than a power of two. That is, it is a
prime number of the form M, = 2n - 1 for some integer n.
Question 2: Drawa flowchart that takes a number as input and determines whether it is a
Armstrong number or not. A number is called Armstrong if sum of cube of all its digits is equal
to that number.
Example: 153 were: 1+5+3 = 1+125 +27
Flow Charts
49
Practical Notebook Computer Science 9
VIVA QUESTIONS AND ANSWERS
Short Questions and Answers
1) What is a flowchart?
Ans:A flowchart is a graphical presentation of the steps to solve a problem.
2) What is the importanceof using a flowchart?
Ans:A flowchart is used to quickly understand the way a problem is solved. A graphical
solution is more effective than a textual one.
3) What do we mean by "input" of a flowchart?
Ans:An input means taking data from a user for further processing.
4) What do we mean by "processing" in flowcharts?
Ans: Processing means the steps upon somedata to solve a problem.
5) Why do we use decision making in problem solving?
Ans: To determine whether a statement is true or false. For example, a year is a leap year or
not, is determined by decision making in a flowchart.
6) What do you mean by "output"in flowcharts?
Ans: It is used to show the results or outcomes of a flowchart.
7) Why do we use the "flow line" symbol in flowcharts?
Ans: It is used to show the flow of steps in a flowchart.
8) For what purpose do we use the "start/terminal" symbol in a flowchart?
Ans: To indicate the start and end of a flowchart.
9) For what purpose do we use the "connector" symbol in a flowchart?
Ans: It is used to connect different parts of a flowchart lying on multiple pages.
10) What is a logical error?
Ans: A logical error is a mistake in a flowchart that provides incorrect results.
11) What is "divide and concur" approach in problem solving?
Ans: It is a strategy to divide a complex problem into subproblems.
50 Flow Charts
Practical Notebook Computer Science9
VIVA QUESTIONS AND ANSWERS
12) What is "candid solution" in problem solving?
Ans:The candid solution represents the spontaneous solution and it is possible that a
candid solution may not be the actual solution of a problem.
13) What are the two basic parameters used to measure the efficiency of an
algorithm?
Ans:Number of steps and amount of memory used to solve a problem are two basic
parameters to measure the efficiency of an algorithm.
14) What are the advantages of flowcharts? Enumerate any three.
Ans: 1. Easy to Draw
2. Easy to understand
3. Easy to identify errors
15) What are the disadvantages of flowcharts? Enumerate any three.
Ans: 1. More time required to draw
2. Modifying is not easy
3. Not suitable for large problems
16) What is test data?
Ans: Test data is used to verify whether a given solution is correct or not.
17) What is a validation?
Ans: Validation means to check whether a solution is correct or not.
18) What is Verification?
Ans: Verification means to check whether the solution is solving the actual problem for
which it was designed.
Flow Charts 51