0% found this document useful (0 votes)
2 views8 pages

G6 Computers Ch5 Flowcharts

Unit 5 focuses on flowcharts, emphasizing their role in breaking down processes into manageable steps and utilizing conditional and loop constructs in programming. Students will learn about flowchart symbols, advantages, and disadvantages, as well as the concepts of counters and accumulators. The unit aims to enhance understanding of how to visually represent algorithms and the flow of control in programming.

Uploaded by

aggarx1a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

G6 Computers Ch5 Flowcharts

Unit 5 focuses on flowcharts, emphasizing their role in breaking down processes into manageable steps and utilizing conditional and loop constructs in programming. Students will learn about flowchart symbols, advantages, and disadvantages, as well as the concepts of counters and accumulators. The unit aims to enhance understanding of how to visually represent algorithms and the flow of control in programming.

Uploaded by

aggarx1a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Unit 5: Flowcharts - Conditional and Loop constructs

Overview:
Ove reiterates the concept of breaking aprocess into smaller processes
graphical form. This
and represerting the
steps in a unit builds on theidea of problern
decornposition and solution
conditionaland loop programming constructs. using
students learn to break
Through this
unit, down instructions such
that they can be easily translated
to program
syntax.

Essential Questions:
Why areflowchartsused in planning a process?
• What are the limitations of a flowchart?

Enduring understanding
Studentswill understand that:
Flowchartsare graphic organizers that us sort and sequences of teps
let arrange to be
carried out in completing a process.

A flowchart does not convey why a specific operation ís done, only how a processís done.
• It is easy to skip important details while creating a flowchart since it involves too rmary
symbols.

Content:
• Definition of Flowchart
• Flowchartsymbols and descriptions of these symbols
Designing Flowchartswith decision constructs
Definition of counters and accumulators
Difference between entry controlled loop and exit controlled loop

• Designing Flowcharts with loop constructs

Essential Vocabulary:
Sequence, Process, Input/Output,Start/Stop, Decision, Counter, Accumulator, Etry
Flowchart,
Controlled loop,Exit controlled loop, Flowlines, Connectors

51
EXYA
SCHOOLs
CMR gobryond

Unit 5 - Flowcharts - Conditional and Loop Constructs

Flowcharts are graphical representations of an algorithm. Flowcharts are easier to understand an


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 This box is used at the


(Terminal Box) beginning or end of the
flowchart. When used in

at the start, START is written in

it and when used in the end,


STOP is written in it.

Input or Output Box This box s used to suggestthe


input of data or the output of

information.

Processing Box This box holds instructions to


do the process act. For
example,statements
like SUM=X+Y, AVG=TOTAL/N
etc. will come in this bOx.

Decision Box This box is used when some


Comparison has to be made.

Arrows or Flowlines This indicates the flow of the

program. It shows the


connection between the
shapes.

Loop
Hexagon indicates the

beginning of repetition of
structure.

Connectors It Connects the flowchart

between two pages.

52
EKYA
SCHOOLs
CMR
Advantages of Flowchart:

1.
Communication: Flowchartsare
better way of
concerned or involved. communicatingthe logic of a
system tO all
2. Proper Debugging:
The flowchart helps in debugging (identify and
program) process. remove errors from computer
3. Efficient Program
Maintenance: The maintenance of
operating programs
help of flowchart. becomes easy with the

Disadvantages of Flowchart:

1. Alterations and Modifications: If


are required the flowchart may
alterations
completely. require re-drawing
Thiswaste valuable time.
will usually
2. Reproduction: As the flowchart
symbols cannot be typed, reproduction of
tedioustask. flowchart becomes a

Various Programming Constructs: We can have three types of programming constructs which
we willbe learning through flowcharts.

|. Sequence construct: In the sequence construct the program flow simply moves from one
statement to another.
Here are some real world Sequence constructs:
1. Process of making fruit juice.
2. Additionof two numbers.

Example
Draw a Flowchart that takes two numbers from the user, Start

add them and givethe result as output isshown here.

Enter 2 numbers:

15and 27

Sum= 15+27

Display sum

Stop

53
EKYA
SCHOOLS
CMR

In this 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 Aand B_are now like boxes. At the time of calculation, A will have a number in it and B wll
have anothernumber in it. And sum is again like a box where the result of A+B will be kept safe.

15 27 42
B Sum

II. Selection or Decision construct:

In the Selection/Decision construct the program control is from a


transferred central instruction to

some other instruction, depending upon the condition met. Here are some real world Selection
constructs:

1. You aregoing for an outing. Draw a 2. Your father has given you some
flowchart to decide whether you money. Draw a flowchart to decide
should carry an "Umbrella"or "Not". whether to buy an ice cream or pizza
from it. If the money given is more
than 50, buy pizza, otherwise buy an
START
ce cream.

Ask "Is
It
raining today?
Start

No Is it Yes
Rainíng? Accept "toney trom father"

Leave Take an
umbrella at umbrella. YES
home IS Money
Buy Pizza

NO
STOP
By lce Cream

54
EKYA
SCHOOS
CMR go beyond

Let us now draw a


flowchart to enter two
numbers and find their sum. If the sum
100, print "More", is greater than
otherwise print "Less".

Start
Termal Bax

Input Box Enter 2numbers Aand 8


where A and B
eunequsl

Pocessng Bex

Example
Accept three numbers and find the average. If the
Now I understand about
averageis greater than 80,print "Good",
fiowchart boxes.
otherwise print "Work Hard".

55
EKYA
SCHOOLs

CMR

IlI. Repetitionor Loop construct:


Start

In the Repetition construct loops are used. A loop is


used to repeat a certain set of commands again and A Bucket is empty
again till a certain condition is met.

Here are some real life examples of loops:


Is the Bucket
1. Potato Race
fullof water?
2. lcing cupcakes.If you've just baked 30 cup
Yes
cakes, you need to apply the same icing
procedure to each one. No
3. Working in a supermarket. Keep serving Pour mug full of

customers until the end of your shift. water ina bucket

4. Filling water in a bucket with a MUG.


Stop

Understanding Counters

You can say that a counter was set to0 in the beginning of each round and when one round gets
completed, it is 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

56
EKYA
SCHOOLS

The above table now can be made like this:

Number fTimes
of
Value of counter CT (CT CT+1)
Before starting the process

After round 1
CT =0+1=1
After round 2 CT =1+ 1 =2
After round 3 CT=2+1=3
After round 4 CT =3+1=4

After round 5 CT= 4 + 1 =5


After round 6 CT=5+1=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 Narne

CT= CT+1
CT= T+1
Open the next Story

Is CT<5 Yes
Is CT<5
Yes
No
No
Stop
Stop

Activity :In the above flowchartsif CT is initialized to 1 CT =


i.e, 1 what will be the change
in the Decision Box ?

57
EKYA
SCHOOLS
CMR

Understanding an Accumulator

If there is some problem like youhave to find thesum of ten numbers entered, you can assiana
variable for this purpose which will store the sum of numbers entered. With each new numb
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 5numbers and find their sum.

Start
Here CT Ís he
cCOunterand SM is the
CT=0, S=0 accumulator.

INPUT N

SM=SM+N

CT-CT+1

owowww

PRINT SM

Stop

Quick Recap

A flowchart the Graphical


is
representation of the sequence of steps
required to solve the particular
D Inprogramming, there are problem.
Sequernce, Decision and Repetition constructs.
In the Sequence
construct, the program flow simply
moves from one statement to the
In the Decision next.
construct, the program control is transferred from a certain
instruction, depending upon the instruction to some other
condition met.
In the Repetition
construct loops are used. A loop
is used to repeat a
is met. certain set of
condition commands again till a
OA Counter is a variable which isused to keep track of the
An AcCumulator number of repetitions in a loop.
is a variable used forthe purpose of
calculating the sum of numbers
entered in a loop.

58

You might also like