0% found this document useful (0 votes)
242 views

Dsa ch2-1 Flowchart

The document discusses flowcharts, pseudocode, and algorithms. It defines flowchart symbols and explains that flowcharts show the logic and flow of an algorithm through a graphical representation. Examples are provided of writing an algorithm to calculate a student's grade, the corresponding pseudocode, and a program to implement the algorithm.

Uploaded by

api-394738731
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
242 views

Dsa ch2-1 Flowchart

The document discusses flowcharts, pseudocode, and algorithms. It defines flowchart symbols and explains that flowcharts show the logic and flow of an algorithm through a graphical representation. Examples are provided of writing an algorithm to calculate a student's grade, the corresponding pseudocode, and a program to implement the algorithm.

Uploaded by

api-394738731
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Data Structure & Algorithms

Chapter :
Flowchart, Pseudo code,
Algorithm
Imran Ali Memon
IT Department
Contents
1. Flowchart Definition
2. Flowchart Symbols
3. Pseudo code
4. Examples
1. The Flowchart
• A graphical representation of the sequence of
operations/instructions in system/program.
• Shows how data flows from sources.
• Shows logic of an algorithm.
• Highlighting individual steps and their
interconnections.
• Control flow from one action to next.
2. Flowchart Symbols
Name Symbol Use in Flowchart

Oval Denotes the beginning or end of the


program

Parallel-o-gram Denotes the input operation

Rectangle Denotes the process to be carried out .


e.g. add, sub, div, mul etc

Diamond Denotes a decision to be made.

Hybrid Denotes an output operation.

Flow line Denotes the direction of logic flow in the


program.
3. Pseudo code
• Pseudo code is an artificial and informal language
that helps programmers develop algorithms.

• Pseudo code is very similar to everyday English.


4. Examples
Example 1:
• Write an algorithm, pseudo code, draw flowchart
and write a program to determine a student’s final
grade and indicate whether it is passing or failing.
• The final grade is calculated as the average of four
marks.
Pseudo code
• Input a set of 4 marks.
• Calculate their average by summing and dividing by
4.
• If average is below 50
Print “Fail”
• Else
Print “Pass”
Algorithm
Step 1: Read M1,M2,M3,M4
Step 2: GRADE <- (M1+M2+M3+M4)/4
Step 3: if GRADE < 50 then
Print “FAIL”
else
Print “PASS”
[endif]
Step4: exit
START

Flowchart

GRADE <-(M1+M2+M3+M4)/4

YES NO
IS
GRADE >50

PRINT PRINT
“PASS” “FAIL”

STOP
Program
#include<iostream.h>
#include<conio.h>
int main(){
int m1, m2, m3, m4, grade;
clrscr();
cin>>m1>>m2>>m3>>m4;
grade = (m1+m2+m3+m4)/4;
if(grade < 50 )
cout<< “fail”;
else
cout<< “pass”;
getch();
return 0;
}
Assignments
Write an algorithm , pseudo code, draw flowchart &
program:
1. To convert the length in feet to centimeter.
2. That will read the two sides of a rectangle and
calculate its area.
3. That reads two values, determines the largest value
and prints the largest value with message.
4. That reads three numbers and prints the value of
largest number.
5. Calculator (+,-,x,/)

You might also like