algorithm and flowchar

Upload: dilip-kumar-rai

Post on 27-Feb-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Algorithm and Flowchar

    1/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 vitalrole 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 writethe program in any high level language. Often we see how flowcharts are helpful in

    eplaining the program to others. !ence, it is correct to say that a flowchart is a must for

    the better documentation of a comple program.

    "lowcharts are usually drawn using some standard symbols# however,

    $tart or end of the program

    %omputational steps or processing function of a program

    &nput or output operation

    'ecision ma(ing and branching

    %onnector or )oining of two parts of program

    The following are some guidelines in flowcharting*

    a. &n drawing a proper flowchart, all necessary requirements should be listed out inlogical 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 topto 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.

  • 7/25/2019 Algorithm and Flowchar

    2/4

    f. Only one flow line is used in con)unction with terminal symbol.

    h. &f the flowchart becomes comple, it is better to use connector symbols to reducethe number of flow lines. Avoid the intersection of flow lines if you want to ma(e

    it more effective and better way of communication.

    i. +nsure that the flowchart has a logicalstartand finish.

    ). &t is useful to test the validity of the flowchart by passing through it with a simpletest data.

    PART II: Eam!le of a flowchart:

    roblem -* rite an algorithm and draw the flowchart for finding the average of two

    numbers

    Algorithm*

    &nput* two numbers and y

    Output* the average of and y

    $teps*

    -. input

    2. input y/. sum 0 1 y

    . average 0 sum 32

    4. output average

    $TA5T

    &nput

    &nput y

    $um 0 1 y

    Average 0 sum32

    Output

    Average

    +6'

  • 7/25/2019 Algorithm and Flowchar

    3/4

    PART III: An eercise

    roblem 2* rite an algorithm for finding the area of a rectangle

    !ints*

    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 inEnglish but such descriptions are often ambiguous and open to misunderstanding.

    Therefore various formal methods of describing algorithms have been developed. Thesimplest of these is the flowchart.

    A flowchart consists of a sequence of instructions linked together by arrows to showthe 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.

    * t is very easy to understand and then to implement the program.* Flowchart uses specific symbols for specific reasoning.

    * t has a proper structure.* !hereas th algorithm is a bit difficult to understand comparing the flow chart.

    * t is a step by step information that depicts the program.* t 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 systeFlowchart is very important tool foe development algorithm # programt 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 ::

    $t 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 byinterconnecting arrows .

    $%imply 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 symbolsprescribed by A&% .

    Algorithm ::

    $Algorithms is step by step execution of the problems and it is clearly mentioned all

    the condition and loop in the algorithms . t is created the algorithm any programmerbefore implementing computer program .

    $Algorithms are one of the most basic tool that are used to develop the program

    solving logic.

  • 7/25/2019 Algorithm and Flowchar

    4/4

    Pseudo Code ::

    $'seudo 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 likeprogramming code .

    $'seudo code is an out line of a program written in a form that can easily converted

    into real programming .

    $'seudo codes uses plain English statements rather than symbols to represent theprocess of computer program.