0 ratings0% found this document useful (0 votes) 619 views10 pagesClass 6 Computer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
1 Algorithm and ag
Flowchart
F teacher,
What doth
terms Algonithny
and Howchart
mean? What ts,
# Dear student
WW this chapter we shall
Wi about alyorithins
and tloweharts,
Computer solves the problems by following the
instructions g
need the
same task to be done by the computer, we ha
instructions again. To avoid this, we can save those instructions in the
set_of instructions is called program. The programs. are
Programming language such as C, C+ +, Java, Python, VB, Cite
Amazing Fact
You can add 2 + 2 quickly and give the answer 4, but
answer only if it has proper instructions to
numbers. And the instructions should be in
Algorithm
The logical sequence of steps for a program is called
English.
Iven to it, Every time
we
ve to feed it the same
computer. Such
written using. various
i.
a computer can give the
add the numbers i.e, how to add the
a computer language.
algorithm. It is written in simple
Algorithm helps in understanding the flow of the intended program easily. Another
advantage of algorithm is to use it to develop its graphical form called Flowchart.
Advantages of Algorithm
# Itis the set of steps arranged in a logical sequence as a solution to a given problem.
* It makes it easier to create the graphical representation of the program flow called
flowchart,
Itis in human language (English in our case) hence easy to understand.
* Itis easy to find logical errors since every step has its own logical sequence.
»
‘Scanned wih ComScannereS
5.
types of boxes and symbols that are connected with arrows/flow lines.
Some common blocks and symbols used to create a flowchart are given here.
Example 1: To calculate the sum of three numbers.
ib
Start.
Input three numbers; x, y and z.
Calculate the sum of three numbers (x+y+z).
Print the sum.
Stop.
Example 2: To find the greater of two numbers.
Start.
Input two numbers, X and Y.
Compare X and Y. If both are equal, go to step 5, else go to step 4.
Compare if X is greater, 80 to step 6, else go to step 7.
Print “Both are equal” and go to step 8.
Print “X is greater” and go to step 8.
Print “Y is greater” and go to step 8.
Stop.
A flow chart generally flows in the direction
from top to bottom or left to right.
Flowchart
A flowchart is a graphical representation of steps of an algorithm. It is a set of different
ere seo io
Taner tao.
Process Box
Sn
‘Scanned wih CamScannerThe flow lines determine the flow through
> Petey
_ \t the chart i.e, they show the direction in
which the program moves.
1 A decision/diamond box checks any
poate condition in the program.
It connects one part of flow chart to
(On nitra rye
another.
Do it Yourself
Identify the various parts of the given flowchart.
Advantages of flowchart
Flowcharts are an easier way to depict the logic of the program.
Flowcharts, being graphical, help greatly in problem analysis.
Flowcharts of any program are good for documentation and later reference.
itations of flowchart
J
2
3.
4. A flowchart helps in debugging process (to remove errors).
Li
1. For complex, large programs flowchart becomes complex and difficult to follow.
2.
If alterations are required the flowchart may require re-drawing completely.
Drawing Flowcharts using Dia
Dia is an easy-to-use, free Flowchart designer. Dia comes as an .exe file so to ensure its
clean and latest version, it is recommended to download it directly from http://dia-
installer.de/. After downloading the .exe file, double click on it to launch it and follow the
simple instructions on the installer screen to install it.
a
‘Scanned wih ComScannerDia Interface
Menu bar: A standard menu bar with various menus.
Standai B vi i
. rd toolbar: It provides quick tools like new, open, save, printand export diagram etc.
iagram Canvas: tis the largest blank area where you can draw the desired diagrams.
Toolbox: 2 7
Pax All the blocks and connecters you need are available in the Toolbox. It also
provides options for line widths and arrow styles.
Drawing Flowcharts in Dia
Click on the desired block in the Toolbox and drag with mouse on the Canvas. The block
will be drawn.
Editing Tools
. Use Arrow tool to move the shape around on the canvas.
Use Text edit tool to type text inside the block or press F2 key on the keyboard.
1
2
3. Use Connectersto connect the blocks with lines and arrows.
4
5.
. Use Line widths to set the line thickness.
. Use Arrow stylesto set desired arrow style.
6. For font, lines and colour settings, double click on the desired block to edit its
properties.
You can use Filemenu > Exportoption to export your chart as an image.
‘Scanned with CemScannerLine width and
Arrow Style:
Une man
|
Line color
|Fatcoter
Oven bechground
Lene enyte
|
Tet pasting 019
[fet torment Corte
Fort vert) tems»
Drew mnge 0 t
|comerradus 020
[tm ue toe
| ese ae, oe
Converting an Algorithm into a Flowchart
Flowcharts are usually drawn from top to bottom, To convert an algorithm into a flow
chart, pick up each statement in the algorithm and find the suitable, matching block of
flowchart. Then connect them from top to bottom or left to right as the space on the
paper allows. Let us see some examples now.
‘Scanned with CemScannerExample 1: To calculate the sum of three numbers
Algorithm [7 Flowchart
1. Start. |
2. Input three numbers; x, y and z. | |
3. Calculate the sum of three numbers; Sum = x | penny s
4. Printthesum. | |
5. Stop. |
Example 2: To find the area of a rectangle.
[ Howchant Algorithm
2. Inputthe length and breadth of the rectangle; L, B.
Calculate the area; Area = Lx B.
Bw
Printthe Area.
Stop.
Do it Yourself
1. Write an algorithm to find the average of five numbers and draw the flowchart also.
2. Write an algorithm to find the perimeter of a rectangle and draw the flowchart also.
3. Draw the Flowchart on paper for the following algorithm
1. Start.
2. Input the radius of circle; R,
3. Calculate the area; Area = = Rx R.
4, Print the Area.
5. Stop.
‘Scanned with CemScannerExample 3: To convert an algorithm into a flowchart to find the greater of two numbers,
Algorithm Flowchart
Start,
Input two numbers, X and Y.
Compare X and Y. if both are equal, goto,
step 5, else go to step 4.
worse
4. Compare if X is greater, go to step 6, else
gotostep 7.
Print “Both are equal” and goto step 8.
6. Print “X is greater” and goto step 8.
. Print “Y is greater” and go to step 8.
8. Stop.
_Do it Yourself = SRS
Write an algorithm to convert feet into inches. Draw
the flowchart also. i
Loop
A loop has a purpose to repeat one or more statements a certain number
until a condition is fulfilled. While using a loop, you need a counter. A counter Is
variable that is used to count the number of times a procedure is being repeated. Its
name could be anything like x, counter, ctr etc.
of times or
A variable is the name of data. It keeps on changing its value during execution of a
program. Its value can be incremented or decremented as per your requirement.
Example 1: To print the name 10 times.
program stops
‘Scanned with CemScannerGlossary.....
Algorithm FI An algorithm is a sequence of steps to solve 2 problem.
Flowchart : A flowchart is a graphical representation of steps of an
algorithm.
A. Choose the correct answer.
1. A/An is used to solve a specific problem..
a
a) Algorithm Ob Program QO
©) Both a) and b) O _ @None of these oO
Wa
tT
‘Scanned wih CamScannerch}
2. A flowchart symbol cannot be typed, This is @ of flowcharts,
a) feature Ow timitation
©) Both a) and b) QC W None of these
OA is used to repeat one oF more statements a certain nunber of times,
a) Loop O b) Algorithm,
©) Flowchart © Program
4 A__may have its value changed during program execution.
a) Flowehart O valgorithm
©) Counter © d) None of them
B. Answer the following questions,
1, What do you mean by the terms: Program, Algorithm and Flowchart?
2. What is the advantage of a flowchart?
2. List advantages of algorithm,
‘Scanned wih ComScannerC. Match the follows
Column-il
1. Flow lines . aD
2. Process box . ~~
3. Decision box . iz
4. Input/output box d. QP
5. Start/stop box e. os
ad) Lab Activity
Create algorithms to solve the following problems and then create Flowcharts using Dia or
PowerPoint shapes or OpenOffice Draw or any other software provided in lab.
1. Accept the age of the user and check, if user is eligible to cast vote (age 18 or above). Ifnot then
display the number of years user should wait to be eligible for voting. If yes then display the
message “You can vote.”
2. Accept numbers from the user and keep them adding until user inputs zero. When a zero is
input, program should display the sum of all the numbers entered and end.
3. Modify the algorithm and flowchart of Problem #2 to not to add any negative numbers input
by the user.
4. A laser printer is printing one page at a time. Computer should display the message “Paper
out!” if paper runs out in the printer and program should end. This should be checked before
printing every page until all the pages are printed.
Teacher's Signature: Teacher's Remark : =>--=>-~
EB https://en.wikiversity.org/wiki/Programming_Logic
oS https://kids.kiddle.co/Flow_chart
Teacher's Corner
Teachers are advised to cite real life examples around students’ daily life to explain the concepts in cn easier
fashion.
W123
tT
‘Scanned with CamScanner