Algorithms & Flow Charts
Algorithms & Flow Charts
Algorithms & Flow Charts
1
INTRODUCTION
Eg. The program:
• Declare variable a, b;
• Sum = a + b;
• Print Sum; OR Cout << sum;
Pseudocode:
1. The program:
2. Declare variable a and b
3. Input: a,b. Output-Sum
4. Enter a and b
5. a and b must be added
6. Output must be stored in Sum
7. Output must be displayed 2
INTRODUCTION
3
CONCLUSION OF INTRODUCTION
5
QUALITIES OF A GOOD ALGORITHM
6
QUALITIES OF A GOOD ALGORITHM
9
Examples Of Algorithms In Programming
10
Pseudocode
11
Pseudocode
12
Pseudocode
13
Class Exercise:
Pseudocode for Students’ Grading System
• Using KNUST grading system, write down the
pseudocode for determining student’s grades
based on the following criteria and
interpretations
• 70 – 100 – A – Excellent
• 60 – 69 – B – Very Good
• 50 – 59 – C – Good
• 40 – 49 – D – Password
• 0 – 39 – F – Fail
14
Class Exercise 2:
• A school conducts a 100 mark exam for its
student and grades them as follows:
Grade:
Grade A: Marks>75
Grade B: 75>Marks>60
Grade C: 60>Marks>50
Grade D: 50>Marks>40
• Write Pseudocode of the grades for a student,
using if. Else statement
15
Class Exercise 2:
Proposed Solution
.
1.input student's grade
2.if grade < 100 AND grade > 75 { student got an A }
3.else if grade < 75 AND grade > 60 { student got a B }
4.else if grade < 60 AND grade > 50 { student got a C }
5.else if grade < 50 AND grade > 40 { student got a D }
6.else { student got an F } // didn't fit into any of the above
scenerios, so must be an F
7.print to screen what the student got
16
Pseudocode
18
FLOWCHART IN PROGRAMMING
• Flowchart is a diagrammatic
representation of an algorithm.
• Flowcharts are graphical methods of
outlining program structure and
generally utilise a set of standard
symbols known as the ANSI (American
National Standards Institute) symbols.
19
FLOWCHART IN PROGRAMMING
20
SYMBOLS USED IN FLOWCHARTS
24
QUESTIONS TIME
25
NEXT TOPIC
26
Reading Assignment
• Write an algorithm to find the factorial of a
number entered by user.
27
References:
1. https://www.programiz.com/article/algorithm-programming
2. http://www.unf.edu/~broggio/cop2221/2221pseu.htm
3. (PDF) Introduction to Algorithms and Pseudocode. Available from:
https://www.researchgate.net/publication/309410533_Introduction_to_A
lgorithms_and_Pseudocode [accessed Aug 30 2018].
4. https://www.proprofs.com/discuss/q/1079057/what-is-the-difference-
between-flowchart-and-pseudocode
28