Saturday, 24 September 2016

Algorithm and Flowchart

                                     

                                    Algorithms

  1. A sequential solution of any program that written in human language is called algorithm.
  2. Algorithm is first step of the solution process, after the analysis of problem, programmer write the algorithm of that problem.
  3. Example of Algorithms:



Q. Write a algorithem to find out number is odd or even?
Ans. 
step 1 : start
step 2 : input number
step 3 : rem=number mod 2
step 4 : if rem=0 then
               print "number even"
           else
               print "number odd"
           endif
step 5 : stop


 

                                  Flowchart


Example of flowchart in our daily life:-





flowchart is a type of diagram that represents
an algorithm, workflow or process, showing the steps as boxes of various kinds, and their order by connecting them with arrows. This diagrammatic representation illustrates a solution model to a given problem. Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields.

                                OR

1. Graphical representation of any program is called flowchart.
2. There are some standard graphics that are used in flowchart as following:

Start/Stop:-Represented as circles, ovals, stadiums or rounded (fillet) rectangles. They usually contain the word "Start" or "End", or another phrase signaling the start or end of a process, such as "submit inquiry" or "receive product".

    

Flow line:- An arrow coming from one symbol and ending at another symbol represents that control passes to the symbol the arrow points to. The line for the arrow can be solid or dashed. The meaning of the arrow with dashed line may differ from one flowchart to another and can be defined in the legend.

                     




Process/Instruction:-Represented as rectangles. This shape is used to show that something is performed. Examples: "Add 1 to X", "replace identified part", "save changes", etc....



Decision Making:-Represented as a diamond showing where a decision is necessary, commonly a Yes/No question or True/False test. The conditional symbol is peculiar in that it has two arrows coming out of it, usually from the bottom point and right point, one corresponding to Yes or True, and one corresponding to No or False. (The arrows should always be labeled.) More than two arrows can be used, but this is normally a clear indicator that a complex decision is being taken, in which case it may need to be broken-down further or replaced with the "predefined process" symbol. Decision can also help in the filtering of data.



Example:- Flowchart to find the greatest common factor (gcd).





No comments:

Post a Comment