Algorithms_ Flowcharts and Number System

Document Sample
Algorithms_ Flowcharts and Number System Powered By Docstoc
Flowcharts and
Number System
Algorithms ?
   A well-defined set of steps to provide a solution of a
    specific problem.
   Characteristics:
        An algorithm should have zero or more input.
        An algorithm should exhibit at least one output.
        An algorithm should be finite.
       Each instruction in an algorithm should be defined clearly.
       Each instruction used in an algorithm should be basic and easy
        to perform.
   Representing an algorithm
       Pseudo-code convention
       Flowcharts

   A graphical tool representing the defined
    solution of a problem.
                 Terminator – the first and last symbol in a flowchart

                 Input/Output – denote input/output
                 function of any input/output device

                  Process – indicate processing
              Indicate flow of program

             Decision – denote a decision-
             making operation in a program

             Connector – a link between parts of a
             flowchart if a flowchart is large and
             unfit in a single page
Rules for Drawing a Flowchart
   It should contain only one starter and one end
   The direction of arrows should be top to bottom
    and left to right.
   It should be simple and drawn clearly and
   The branches of decision box must be labeled.
Advantages / Disadvantages
   Advantages
       Provides convenient method to understand the solution.
       Good tool for documentation.
       Provide guide for coding.
   Disadvantages / Limitations
       Not suitable for large programs.
       Complex logic: Sometimes, the program logic is quite
       Alterations and Modifications: If alterations are required the
        flowchart may require re-drawing completely.
Example #1
   Convert temperature
    from Fahrenheit to
Example #2
   Convert days into
    months and days
Example #3
   Interchange the value
    of two numbers
Example #4
   Read marks of 4 subjects, and print grade of the
    student according to total marks obtained
Total Marks        Grade
    > 800                A
    601 – 800            B
    401 – 600            C
    201 – 400            D
Example #5
  Calculate the
factorial of
a number
Example #6
   Check whether a
    number is prime
Example #7
   flowchart to find the sum
    of first 50 natural
Example #8
 find the largest of three
numbers A,B, and C.

Correct ?
   Draw a flowchart to read a number N and print all its
   Draw a flowchart for computing the sum of the digits of
    any given number
   Draw a flowchart to find the sum of given N numbers.
   Draw a flowchart to computer the sum of squares of
    integers from 1 to 50
   Draw a flowchart to arrange the given data in an
    ascending order.
 110 Computer Programming
   The Architecture of Computer Hardware and Systems
    Software: An Information Technology Approach,
     Linda Senne, Wilson Wong, Bentley College

Shared By: