Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CS102 Computer Programming I: Flowcharts

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

CS102

Computer Programming I

Lecture 3: FLOWCHARTS

Bicol University College of Science


CSIT Department
1st Semester, 2019-2020
Flowcharts
- Pictographic Representation of
Algorithms

2
What is a Flowchart?
 A flowchart is a diagrammatic representation that
illustrates the sequence of operations to be
performed to get the solution of a problem.

 generally drawn in the early stages of formulating


computer solutions

 facilitate communication between programmers and


business people

 play a vital role in the programming of a problem and


is helpful in understanding the logic of complicated
and lengthy problems

3
Flowchart Symbols
 Start or end of the program

 Computational steps or processing function


of a program

 Input or output operation

 Decision making and branching

 Connector or joining of two parts of program

4
Flowchart Symbols
 Magnetic Tape

 Magnetic Disk

 Off-page connector

 Flow line

 Annotation

 Display

5
Flowchart Guidelines

In drawing a proper flowchart, all necessary
requirements should be listed out in logical
order.

The flowchart should be clear, neat and easy
to follow. There should not be any room for
ambiguity in understanding the flowchart.

The usual direction of the flow of a procedure
or system is from left to right or top to
bottom.

Only one flow line should come out from a
process symbol.

6
Flowchart Guidelines
Only one flow line should come out from a
process symbol.

7
Flowchart Guidelines
Only one flow line should enter a decision
symbol, but two or three flow lines, one for
each possible answer, should leave the
decision symbol

Y N

8
Flowchart Guidelines
Only one flow line is used in conjunction with
terminal symbol

9
Flowchart Guidelines
Write within standard symbols briefly. As
necessary, you can use the annotation
symbol to describe data or computational
steps more clearly.

This is top secret

10
Flowchart Guidelines

If the flowchart becomes complex, it is better to
use connector symbols to reduce the number
of flow lines. Avoid the intersection of flow lines
if you want to make it more effective and better
way of communication.

Ensure that the flowchart has a logical start
and finish.

It is useful to test the validity of the flowchart
by passing through it with a simple test data.

11
Advantages Of Using
Flowcharts
The benefits of flowcharts are as follows:

1. Communication: flowcharts are better way of


communicating the logic of a system to all
concerned.
2. Effective analysis: with the help of flowchart,
problem can be analyzed in more effective
way.
3. Proper documentation: program flowcharts
serve as a good program documentation,
which is needed for various purposes.

12
Advantages Of Using
Flowcharts (cont'd)
4. Efficient coding: the flowcharts act as a guide
or blueprint during the systems analysis and
program development phase.
5. Proper debugging: the flowchart helps in
debugging process.
6. Efficient program maintenance: the
maintenance of operating program becomes
easy with the help of flowchart. It helps the
programmer to put efforts more efficiently on
that part.

13
Limitation Of Using
Flowcharts
 Complex logic: sometimes, the program logic is quite
complicated. In that case, flowchart becomes complex
and clumsy.
 Alterations and modifications: if alterations are
required the flowchart may require re-drawing completely.
 Reproduction: as the flowchart symbols cannot be
typed, reproduction of flowchart becomes a problem.
 The essentials of what is done can easily be lost in the
technical details of how it is done.

14
Algorithm (Pseudocode)
1.sum = 0
2.n = 0
3.n = n + 1
4.sum = sum + n
5.if n = 10 then
print sum
else
go to #3
end-if

15
A Sample Flowchart
start

sum = 0

n=0

n=n+1 print sum

sum = sum + n
stop
no yes
Is n = 10?

16
Sum N numbers pseudocode:
• get a value for n
• set the value of sum to 0
• while n > 0 do:
• sum = sum + n
• n=n-1
• end-while
• display the value of sum
ACTIVITY 3
A) Given the sides of a parallelogram, write an algorithm to
determine its type (i.e. rectangle or square).
B) Write an algorithm to raise any number to any power.
C)Write an algorithm to produce the first 15 numbers of this
series: 1,1,2,3,5,8,13,21...
D)Make a formula to compute the number of days before
Christmas given any date.
E) During the summer you get a job as DJ at a small radio
station that only plays teenagers’ music. To make your
program more attractive, you run a contest: you will receive
ten phone calls from the public, and afterwards, you will
award a thoughtful prize to the oldest member of your
audience. Note the following: (i) you receive one call at a
time, (ii) you do not know when the next call will occur, (iii)
you are not allowed to disclose the age at any moment.
ACTIVITY 3
F) Write the algorithm that will determine if the
given year is a leap year.
2
G) Given the formula y = 0.5x – 3, describe the
steps needed to get the list of Y-values, for a
range of X-values from –3 to +3.
H) Given the table on the right, find the formula that
relates variable X with variable Y and describe the
steps needed to get the list of Y-values.

I) Break the formula down in several steps.


End of Lecture 3

You might also like