Flow Charts
Flow Charts
Flow Charts
Flowcharts are graphical representation of an algorithm. Flowcharts are easier to understand as the flow
of sequence is easily understood.
Before we draw a flowchart we need to know that there are different symbols for different types of
instructions.
Start or Stop Box (Terminal Box) This box is used at the beginning or
end of the flowchart. When used in
the start, START is written in it and
when used in the end, STOP is
written in it.
Input or Output Box This box is used to suggest the input
of data or the output of information.
Advantages of Flowchart:
1. Communication: Flowcharts are better way of communicating the logic of a system to all
concerned or involved.
2. Proper Debugging: The flowchart helps in debugging (identify and remove errors from computer
program) process.
3. Efficient Program Maintenance: The maintenance of operating program becomes easy with the
help of flowchart.
Disadvantages of Flowchart:
1. Alterations and Modifications: If alterations are required the flowchart may require re-drawing
completely. This will usually waste valuable time.
2. Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart becomes a
tedious task.
Various Programming Constructs: We can have three types of programming
constructs which we will be learning through flowcharts.
I. Sequence construct:
In the sequence construct the program flow simply moves from one statement to another.
Example
Draw a Flowchart that takes two numbers from the user, add them and give the result as output
is shown here.
Start
Enter 2 numbers:
15 and 27
Sum= 15 +27
Display sum
Stop
In the above example always a specific set of given numbers (15, 27) are getting added. But this
flowchart can be used for any general 2 numbers with a slight modification in input box, like given
below:
Enter 2 numbers A
and B
Now A and B are now like boxes. At the time of calculation, A will have a number in it and B will
have another number in it. And sum is again like a box where the result of A + B will be kept safe.
15 27 42
A B sum
Ask "Is It
raining today ?
" Accept “Money from father”
No Is it Yes
Raining?
YES
IS Money
Leave Take an > 50 Buy Pizza
umbrella at umbrella.
home NO
Let us now draw a flowchart to enter two numbers and find their sum. If the sum is greater than 100,
print “More”, otherwise print “Less” .
Start
Terminal Box
No PRINT “MORE”
PRINT “LESS”
Output Box
Stop
Now I understand about
flowchart boxes.
Example
Accept three numbers and find the average. If the average is greater than 80, print “Good”,
otherwise print “Work Hard”.
Start
AVG=(A+B+C)/3
Is
AVG>80 Yes
PRINT “GOOD”
No
Stop
A Bucket is empty
Is the Bucket
full of water?
Yes
No
Pour mug full of
water in a bucket
Stop
Understanding Counters
You can say that a counter was set to 0 in the beginning of each round and when one round gets
completed, it was incremented by 1.
If the counter is denoted by the variable CT, its value is incremented by the process CT=CT+1,
where CT on the left side of the “=” sign stores the latest value that is being calculated on the right
side, by adding 1 to the old values of CT after each round.
<final value of CT> = <old value of CT > +1
Round Counter
In the beginning 0
After first round 1
After Second round 2
And --So on -- --So on --
After sixth round 6
The counter is a variable which is used to keep track of the number of repetition in a loop.
Example Example
To read five stories from a book. To print your name five times.
Start
Start
CT = 0
CT=0
Accept Name
Start Reading the Story
Print Name
CT= CT+1
Open the next Story CT = CT + 1
Is CT < 5 Yes
Is CT < 5
Yes
No
Stop No
Stop
Activity In the above flowcharts if CT is initialized to 1 i.e , CT = 1 what will be the change
in the Decision Box ?
Understanding an Accumulator
If there is some problem like you have to find the sum of ten numbers entered, you can assign a
variable for this purpose which will store the sum of numbers entered. With each new number entered,
its value will increase by the value of the new number entered.
An Accumulator is a variable used for the purpose of calculating the sum of numbers entered in
a loop.
Example
A flowchart to accept 5 START Number Accumulator
numbers and find their sum. Entered (SM)
CT = 0, SM = 0 No Initial Value = 0
Number
entered yet
INPUT N
5 0+5=5
SM = SM + N
7 5 + 7 =12
CT = CT +1
6 12 + 6 =18
Yes Is CT < 5
4 18 + 4 = 22
No
PRINT SM
8 22 + 8 = 30
STOP
Here CT is the
counter and SM is the
accumulator.
Quick Recap
¤ A flowchart is the Graphical representation of the sequence of steps required to solve the particular
problem.
¤ In programming, there are Sequence, Decision and Repetition constructs.
¤ In the Sequence construct, the program flow simply moves from one statement to next.
¤ In the Decision construct, the program control is transferred from a certain instruction to some other
instruction, depending upon the condition met.
¤ In the Repetition construct loops are used. A loop is used to repeat a certain set of commands again till
a condition is met.
¤ A Counter is a variable which is used to keep track of the number of repetitions in a loop.
¤ An Accumulator is a variable used for the purpose of calculating the sum of numbers entered in a loop.
Quick Practice
Draw a flowchart to accept numbers from a user and also find their sum. After each entry of
number, the program should prompt the user, “do you want to enter more numbers”. If the choice
is “Yes”, the program should continue, otherwise print the sum and the process should stop.
START
Sum=0
Accept Num
Yes Is Choice =
"Yes"
No
Print Sum
STOP
Exercise Time
1. Write (T) for True and (F) for False statements.
Practice Time
1. Use MS WORD to create a flowchart that finds the average of any 3 numbers.
2. Create a flowchart that decides if you can go out with friends on Saturday. Check for conditions
like parents’ approval, timings, school working or not working etc.
3. Accept three numbers, multiply them and print their result.
4. Accept two numbers. Find their sum. If the sum is greater than 50 multiply the first number by 5
and print the result, otherwise multiply the second number by 5 and print the result.
5. Accept two different numbers. If the first number A is greater than the second number B subtract
the first number from the second number and print the result, otherwise subtract the second
number from the first number and print the result.
6. Input the numbers through a loop. The loop should continue as long as the sum of the numbers
entered is less than 99.
7. To input ten non-zero numbers and print how many are +ve and how many are –ve.
8. Accept the marks in marks in Math and Science of five students and find their sums individually.
9. Create a flowchart to calculate the area of a square and a rectangle. Try adding a menu that lets the
user choose between square and rectangle.