RSS

What is Algorithm,Pseudo-code and Flowchart


Introduction to Programming in C++
Algorithm,Pseudo-code and Flowchart

An Algorithm is Simply a Solution to a Problem or A step by step Procedure to solve a problem is called Algorithm. 


There are two commonly used tools to help to document program logic (the algorithm). These are 


Pseudo-code and Flowcharts.

Pseudo-code is a General way of  Describing an Algorithm or Pseudo code is one of the methods that could be used to represent an algorithm.

Pseudo-code does not use the Syntax of a Specific Programming Language, therefore cannot be executed on a computer. But it closely resembles the Structure of a Programming language and contains roughly the same level of detail.

Flowchart is a Diagrammatic representation of an Algorithm. Flowchart are very helpful in writing program and explaining program to others


Examples of Algorithm,Pseudo-code and Flowchart:


Now we are going to see an Example of a Algorithm,Flowchart and Pseudo-code of  Program that will Computes the Sum, Average and Product of three numbers: 


Algorithm:


Step1: Read three numbers form User as a Input

Step2: Compute the sum of that three numbers
Step3: Compute the Average of that three numbers 
Step4: Compute the Product of that three numbers
Step5: Output the Sum,Average and Product


    Flowchart                          Pseudo-code

                                                                      
                            
                 1)  Read X, Y, Z 

                 2) Compute Sum (S) as X + Y + Z 


                 3)  Compute Average (A) as S / 3 


                 4)  Compute Product (P) as X x Y x Z 


                 5)  Write (Display) the Sum, Average                            and Product 





What is the difference between Algorithm and Pseudo-code?
An algorithm is a well defined sequence of steps that provides a solution for a given problem, while a Pseudo-code is one of the methods that can be used to represent an algorithm. While algorithms can be written in natural language, pseudocode is written in a format that is closely related to high level programming language structures. 
But Pseudo-code does not use specific programming language syntax and therefore could be understood by programmers who are familiar with different programming languages. Additionally, transforming an algorithm presented in pseudo-code to programming code could be much easier than converting an algorithm written in natural language.
Posted by Irfan Doggar

------------------------------

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS
X-Steel Pointer