Algorithms_ Flowcharts and Number System

Document Sample

```					Algorithms,
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
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
Flowcharts
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
symbol.
   The direction of arrows should be top to bottom
and left to right.
   It should be simple and drawn clearly and
neatly.
   The branches of decision box must be labeled.
   Provides convenient method to understand the solution.
   Good tool for documentation.
   Provide guide for coding.
   Not suitable for large programs.
   Complex logic: Sometimes, the program logic is quite
complicated.
   Alterations and Modifications: If alterations are required the
flowchart may require re-drawing completely.
Example #1
   Convert temperature
from Fahrenheit to
Celsius
Example #2
   Convert days into
months and days
Example #3
   Interchange the value
of two numbers
Example #4
student according to total marks obtained
> 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
numbers.
Example #8
 find the largest of three
numbers A,B, and C.

Correct ?
Exercise
   Draw a flowchart to read a number N and print all its
divisors.
   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.
Ref.
   http://media.en.kku.ac.th/188 110 Computer Programming
   http://www.nos.org/htm/basic2.htm
   The Architecture of Computer Hardware and Systems
Software: An Information Technology Approach,
Linda Senne, Wilson Wong, Bentley College

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 443 posted: 7/11/2011 language: English pages: 19