Sunteți pe pagina 1din 4

Lab 2 Introduction to Flowcharts and Algorithms

Name: __________________________
Lab 2 aims at introducing you to flowcharts and emphasizing on algorithms.
PART I: Introduction to flowcharts
A flowchart is a graphical representation of an algorithm. These flowcharts play a vital
role in the programming of a problem and are quite helpful in understanding the logic of
complicated and lengthy problems. Once the flowchart is drawn, it becomes easy to write
the program in any high level language. Often we see how flowcharts are helpful in
explaining the program to others. Hence, it is correct to say that a flowchart is a must for
the better documentation of a complex program.
Flowcharts are usually drawn using some standard symbols; however,
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

The following are some guidelines in flowcharting:


a. In drawing a proper flowchart, all necessary requirements should be listed out in
logical order.
b. The flowchart should be clear, neat and easy to follow. There should not be any
room for ambiguity in understanding the flowchart.
c. The usual direction of the flow of a procedure or system is from left to right or top
to bottom.
d. Only one flow line should come out from a process symbol.

or
e. 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.

f. Only one flow line is used in conjunction with terminal symbol.

h. 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.
i. Ensure that the flowchart has a logical start and finish.
j. It is useful to test the validity of the flowchart by passing through it with a simple
test data.
PART II: Example of a flowchart:
Problem 1: Write an algorithm and draw the flowchart for finding the average of two
numbers
START
Algorithm:
Input: two numbers x and y

Input x

Output: the average of x and y


Input y

Steps:
1.
2.
3.
4.
5.

input x
input y
sum = x + y
average = sum /2
output average

Sum = x + y

Average = sum/2

Output
Average
END

PART III: An exercise


Problem 2: Write an algorithm for finding the area of a rectangle
Hints:

define the inputs and the outputs


define the steps
draw the flowchart

An algorithm is a description of how to carry out a process. An algorithm lists the


steps that must be followed to complete the process. Algorithms can be described in
English but such descriptions are often ambiguous and open to misunderstanding.
Therefore various formal methods of describing algorithms have been developed. The
simplest of these is the flowchart.
A flowchart consists of a sequence of instructions linked together by arrows to show
the order in which the instructions must be carried out. Each instruction is put into a
box. The boxes are different shapes depending upon what the instruction is.
Flowchart is a flow or sequence of information pertaining to a particular program.
* It is very easy to understand and then to implement the program.
* Flowchart uses specific symbols for specific reasoning.
* It has a proper structure.
* Whereas th algorithm is a bit difficult to understand comparing the flow chart.
* It is a step by step information that depicts the program.
* It does not include any specific symbols.
An Algorithm is a precise rule / set of rules how to solve some problem
A Flowchart is a diagram of the sequence of operations in a computer program or an
accounting syste
Flowchart is very important tool foe development algorithm & program
It is pictorial representation of step by step solution of a problem
Algorithm refers to the logic .
Algorithm is define as sequence of instruction that when executed in the specified
sequence the desired results are obtained
Flow Chart ::
-It is simple flowchart is pictorial representation of an algorithms in which the steps
are drawn in the form of different shapes of boxes and the logical flow is indicated by
interconnecting arrows .
-Simply we say it is a blue print of program and it is drawing a blue print before
writing the computer program .
- The flowchart is drawn according to defined rules and using standard symbols
prescribed by ANSI .
Algorithm ::
-Algorithms is step by step execution of the problems and it is clearly mentioned all
the condition and loop in the algorithms . It is created the algorithm any programmer
before implementing computer program .
-Algorithms are one of the most basic tool that are used to develop the program
solving logic.

Pseudo Code ::
-Pseudo means imitation and code refers to instructions written in a programming
languages but pseudo is not real programming code but it models and even look like
programming code .
-Pseudo code is an out line of a program written in a form that can easily converted
into real programming .
-Pseudo codes uses plain English statements rather than symbols to represent the
process of computer program.

S-ar putea să vă placă și