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

Flowcharting Algorithms

Uploaded by

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

Flowcharting Algorithms

Uploaded by

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

FLOWCHARTING & ALGORITHMS

Key terms

Abstraction - the process of hiding information


that is not needed to know at the time; to use the
overall essential concept with details hidden.
Algorithm - a process to solve a problem.
Function - a combination of variables and
operators.
Key terms
Heuristic - a technique, a way to try to solve, an
idea to use to look for the answer to a problem
which may or may not be solved by the technique.
Iteration - to do again, a repetition of an existing
process.
Method - a set of instructions telling a computer
the operations to perform for a problem solution.
Key terms
Operator - a character symbol like a plus sign in
math, +, or a word or specially defined symbol
usage in a programming language, that tells the
computer to do something with variables.
Key terms
Procedure - another word for method.
Solvable Problems - problems that can be solved
with algorithms to an exact answer, a computer
can find the exact answer.
Unsolvable Problems - problems that are
indeterminate in their solution for a computer.
Key terms
Variable - a programming word made up of
letters, numbers, and/or allowable symbols which
holds data for the program.
ALGORITHMS AND FLOWCHARTS
• Computer programming can be divided into two
phases:
• Problem-solving phase
Make an ordered sequence of steps that solves a
problem.
This sequence of steps is called an algorithm.
• Implementation phase
Implement using a programming language.
Phases in the Programming Task
1. Problem Solving Phase
Understand (define) the problem and what
Analysis and Specification
the solution must do

Develop a comprehensive unambiguous


Algorithm Development
logical sequence of steps to solve the problem

Verification of Algorithm Follow steps closely (manually) to see if


solution works
Example Analysis and Specification
Example of Algorithm Development
In this example:
def verify_even_odd(number):
We define a function verify_even_odd that takes a
if number % 2 == 0: number as input.
return "Even" Inside the function, we use the modulus operator % to
check if the number is divisible by 2.
else: If the number is divisible by 2 (i.e., the remainder is 0),
return "Odd" we return "Even", otherwise, we return "Odd".
We then test the function with some example numbers.

# Test the function


print(verify_even_odd(5)) # Output: Odd
print(verify_even_odd(8)) # Output: Even

Example of Verification Algorithm


Phases in the Programming Task
2. Implementation Phase

Program Development Program Testing

Translate the algorithm into a Test program for syntactical


program written in a and logical errors. Fix the
programming language errors.
Algorithm: Calculate Rectangle Area

1. Start
2. Declare variables length, width, and area as
floating-point numbers.
3. Prompt the user to enter the length of the
rectangle.
4. Read and store the value of length.
5. Prompt the user to enter the width of the
rectangle.
6. Read and store the value of width.
7. Calculate the area of the rectangle using the
formula: area = length * width.
8. Display the calculated area.
9. End.

Example of Program Development


Example of Program Testing
Example of Program Testing
Steps in Problem Solving
• Pseudocode is an artificial and informal language that
helps programmers develop algorithms.
• First produce a general algorithm (one can use
pseudocode).
• Refine your steps until you get to an easy sequence.
Perhaps use numbers or bullets. The point is to simplify
the language to an understandable process or event.
The Flowchart
A Flowchart is another algorithm but graphical.
• Shows the logic solution
• Emphasizes individual steps and their
interconnections
• A flowchart must have a start and stop.
• All steps in a flowchart must connect. Can’t leave a
step “hanging” with no connection.
• e.g. control flow from one action to the next
The Flowchart
A Flowchart is another algorithm but graphical.
• Shows the logic solution
• Emphasizes individual steps and their
interconnections
• A flowchart must have a start and stop.
• All steps in a flowchart must connect. Can’t leave a
step “hanging” with no connection.
• e.g. control flow from one action to the next

You might also like