Understanding Flow Chart, Pseudo Code

& Algorithms Implementation using C++ Flow Chart Pseudo Code

& Algorithm Prepared by Dinesh. D References Flow

Chart Basic

Symbols Basic

Structures Basic Symbols The SEQUENCE process is just a series of processes carried out one after and other. Most programs are represented at the highest level by a SEQUENCE, possible with a loop from the end back to the beginning. Sequence Structure A flowchart for computing the factorial If-Then-If Structure The If - Then - If process logically completes the binary decision block by providing two separate processes. One of the process will be carried out in the each path from the binary decision. The WHILE process allows for the representation of a conditional loop structure within a program. The decision to execute the process in the loop is made prior to the first execution of the process. While Structure The DO-WHILE structures differs from the while structure in that the process contained within the loop is always executed at least one time. This equivalent to performing the process once before going into a WHILE loop. In the WHILE Structure the process may never be executed. Although the WHILE structure is preferred the DO-While structure is sometimes more intuitive Do-While Structure Similarly, the CASE structure is useful in representing a series of IF-THEN-ELSE statements where there are more than two choices to be made. Hence the DECISION blocks are identical except for the choice being compared. The true result always flows to the right., with the false result flowing into the next DECISION block. There will always be one less DECISION block than the number of choices. Case Structure Derived

Structures Sequence Structure Age Calculator Initialize

Current Year Initialize Birth Year calculate

Age If-Then-If Structure Result System is average

greater than 50? Diplay result

as "Pass" Diplay result

as "Fail" While Structure is result

less than 10? Double result Do-While Structure is result

less than 10? Double result Yes No Yes No Case Structure Yes Yes Yes Yes No No No No Is Grade = "A"? Is Grade = "B"? Is Grade = "C"? Is Grade = "D"? Points=4 Points=3 Points=2 Points=1 Points=0 Pseudocode & Algorithm An algorithm is a procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed. An algorithm is merely the sequence of steps taken to solve a problem. The steps are normally "sequence," "selection, " "iteration," and a case-type statement.

Pseudocode is a kind of structured english for describing algorithms.

Pseudocode is an artificial and informal language that helps programmers develop algorithms. Pseudocode is a "text-based" detail (algorithmic) design tool. Examples Pseudocode Algorithm Begin

Input height & width of rectangle

Calculate the area of rectangle

Display the area of rectangle

End. input w,h;

a=w*h;

print a; Sequence Structure Initialize

Celsius Temprature Convert to Fahrenheit Display Tempratures 1. initialize x

2. calculate y=9*x/5+32

3. display x,y int x=10;

int y;

y=9*x/5+32;

cout<<x<<"C"<<'\n';

cout<<y<<"F"<<'\n'; If-Then-If Structure is average

greater than 50? Diplay result

as "Pass" Diplay result

as "Fail" 1. if x>50, display "Pass"

2. else, display "Fail" if (x>50)

{

cout<<"Pass";

}

else

{

cout<<"Fail";

} While Structure is result

less than 10? Double result Yes No while (x<10)

{

x=x*2;

} Do-While Structure is result

less than 10? Double result Yes No 1. x=x*2

2. if (x<10), go to 1 do

{

x=x*2;

}

while (x<10); Case Structure Yes Yes Yes Yes No No No No Is Grade = "A"? Is Grade = "B"? Is Grade = "C"? Is Grade = "D"? Points=4 Points=3 Points=2 Points=1 Points=0 1. If grade is A, points=4 and go to 6

2. If grade is B, points=3 and go to 6

3. If grade is C, points=2 and go to 6

4. If grade is D, points=1and go to 6

5. points=0

6. Terminate program switch (Grade) {

case 'A':

{

points=4;

break;

}

case 'B':

{

points=3;

break;

}

case 'C':

{

points=2;

break;

}

case 'D':

{

points=1;

break;

}

default:

{

points=0;

}

} 1. if (x<10), goto 2

2. double result (x=x*2) Circumference calculator Start Input r Initialize

pi=3.142 a=2*pi*r Output a Stop 1. Start

2. Initialize pi=22/7

3. input r

4. calculate a=2*pi*r

5. output a

6. End {

int a,r;

const pi=3.142;

cin>>r;

a=2*pi*r;

cout<<a;

} Area Calculator Start Input r Initialize

pi=3.142 a=pi*r*r Output a Stop 1. Start

2. Initialize pi=22/7

3. input r

4. calculate a=pi*r*r

5. output a

6. End {

int a,r;

const pi=3.142;

cin>>r;

a=2*pi*pow(r,2);

cout<<a;

} *

*

*

*

*

*

* www.prezi.com

www.maths.udsm.ac.tz/mujuni/mt512/Algorithms.pdf

en.wikipedia.org/wiki/Algorithm

www.eod.gvsu.edu/~blaucha/c2d2/Structured%20Design%20Using%20Flowcharts.pdf

www.rff.com/structured_flowchart.htm

http://www.daniweb.com/software-development/computer-science/threads/25161

http://userpages.wittenberg.edu/bshelburne/Comp150/Algorithms.htm Yes No Yes No

### Present Remotely

Send the link below via email or IM

CopyPresent to your audience

Start remote presentation- Invited audience members
**will follow you**as you navigate and present - People invited to a presentation
**do not need a Prezi account** - This link expires
**10 minutes**after you close the presentation - A maximum of
**30 users**can follow your presentation - Learn more about this feature in our knowledge base article

# Dinesh. D

Flow charts, Pseudo codes & Algorithms

by

Tweet