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

Algorithms & Flow Charts

The document discusses pseudocode, flowcharts, and algorithms. It defines pseudocode as a textual representation of an algorithm that lists the logical functions and inputs/outputs. Flowcharts are graphical representations of algorithms using standard symbols. The document provides examples of pseudocode and exercises for students to write pseudocode for grading systems and flowcharts for adding numbers. It also discusses qualities of good algorithms and examples of common algorithms.

Uploaded by

Kaptain Suraj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Algorithms & Flow Charts

The document discusses pseudocode, flowcharts, and algorithms. It defines pseudocode as a textual representation of an algorithm that lists the logical functions and inputs/outputs. Flowcharts are graphical representations of algorithms using standard symbols. The document provides examples of pseudocode and exercises for students to write pseudocode for grading systems and flowcharts for adding numbers. It also discusses qualities of good algorithms and examples of common algorithms.

Uploaded by

Kaptain Suraj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

INTRODUCTION

Pseudocode, on the other hand, is a


textual representation of an algorithm.
It lists out all the logical functions an
algorithm will do including the input and
the output of the program.

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

• A flowchart is the graphical or pictorial


representation of an algorithm with the
help of different symbols, shapes and
arrows in order to demonstrate a process
or a program.

3
CONCLUSION OF INTRODUCTION

Take note that flowchart is normally used to


represent the algorithm in a diagrammatic
manner. OR A flowchart is a diagrammatic
description of an algorithm.

Pseudocode is a method of describing


computer algorithms using a combination of
natural language and programming
language.
4
Algorithm in programming

In programming, algorithms are the set of


well defined instruction in sequence to
solve a problem.

An algorithm should always have a clear


stopping point.

5
QUALITIES OF A GOOD ALGORITHM

• Inputs and outputs should be defined


precisely.

• Each steps in algorithm should be clear


and unambiguous.

6
QUALITIES OF A GOOD ALGORITHM

• Algorithm should be most effective


among many different ways to solve a
problem.

• An algorithm shouldn't have computer


code. Instead, the algorithm should be
written in such a way that, it can be used
in similar programming languages.
7
EXAMPLES OF ALGORITHM

• Algorithm to add two numbers


• Algorithm to find the largest among
three numbers
• Algorithm to find all the roots of
quadratic equation
• Algorithm to find the factorial
• Algorithm to check prime number
8
Examples Of Algorithms In Programming

• Write an algorithm to add two numbers


entered by user.

9
Examples Of Algorithms In Programming

Write an algorithm to add two numbers


entered by user.

10
Pseudocode

• Pseudocode is an artificial and informal


language that helps programmers
develop algorithms.

• Pseudocode is a "text-based" detail


(algorithmic) design tool.

11
Pseudocode

• The rules of Pseudocode are reasonably


straightforward. All statements showing
"dependency" are to be indented.

• These include while, do, for, if, switch.


Examples below will illustrate this notion.

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

• Pseudocode can be very useful for


specifying the logic of a computer
program (or some critical portion of a
program) prior to that program being
written.

• It's also useful for documenting the logic


of a computer program after the fact.
17
Pseudocode

• It can be used to express the high-level


logic of an entire program, the lower-
level details of a core function in an
operating system or run-time library, the
behaviors and methods in an agent-
based or object- oriented program, and
everything in between.

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

• Flowchart are very helpful in writing


program and explaining program to
others.

20
SYMBOLS USED IN FLOWCHARTS

• Different symbols are used for different


states in flowchart, For example:
Input/Output and decision making has
different symbols.

• The table below describes all the symbols


that are used in making flowchart
SYMBOLS USED IN FLOWCHARTS
SYMBOLS USED IN FLOWCHART
EXAMPLES OF FLOWCHARTS IN
PROGRAMMING

• Draw a flowchart to add two numbers


entered by user.

24
QUESTIONS TIME

25
NEXT TOPIC

• Introduction to C++ programming


• Software Installation and fundamental
concepts

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

You might also like