0% found this document useful (0 votes)
37 views15 pages

2.5 - Flowcharts

Uploaded by

ezedean.dahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views15 pages

2.5 - Flowcharts

Uploaded by

ezedean.dahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Flowcharts

ICS 3U0
Today’s Agenda
Go into more detail about the design stage of the
Software Development Life Cycle

Learn about tools to help with good software design


such as writing pseudocode, writing algorithms,
and creating flow charts
Pseudocode
 Computational algorithms are often described using
pseudocode.

 In fact, if pseudocode is well-written, it is usually fairly


easy to translate it into a computer program, assuming
that the programmer is familiar with a language’s
syntax and commands.
Pseudocode Guidelines
While there are no official rules concerning pseudocode,
here are some recommended guidelines:

 Write one statement per line. This ensures each task is clearly
identifiable at a glance.
 Use a verb as a keyword, and capitalize it for emphasis. This makes
it easy to spot the actions involved in the task.
 Use indentation to group related tasks, such as decisions or
repetitive processes. This makes pseudocode more readable.
 Ensure that pseudocode is language-independent. An individual
should be able to follow your pseudocode without requiring
knowledge of a specific programming language.
Example of Pseudocode
An example of pseudocode for making buttered toast.

PUT bread in toaster


PRESS lever down so toaster is on
WHILE bread is not toasted
WAIT for bread to turn golden brown
POP toast up
PUT toast on plate
SPREAD butter onto toast
Pseudocode and Actual Code
Pseudocode Actual Code

GENERATE random number import random


between 1 and 10 num = random.randint(1,10)
READ guess guess = int(input("Guess: "))
SET count = 1 count = 1
WHILE guess not equal to while guess != num:
random number guess = int (input
READ guess ("Nope. Guess again: "))
INCREMENT count by 1 count += 1
PRINT count print("Correct! You guessed
the number in", count,
"guesses!")
Flowcharts
 Some people prefer to design code graphically, so that
they can visualize program flow better.

 Flowcharts are graphical representations ofalgorithms.


They use standard symbols to represent different
actions, and connect each step in some logical
sequence.
Flowchart Symbols
 The graphic to the right shows some of the more
common symbols used. There are many more, but
this lesson only covers a small subset. We will
introduce other symbols as necessary.

 Each flowchart begins and ends with a terminator.


This indicates where the algorithm starts, and where
it finishes – it’s an oval.
 Between the terminators, each step is connected by
an arrow indicating which step follows another
called a connector.
Flowchart Symbols
Other common symbols used are:

• Parallelogram: indicates input or output,


such as reading data from the user or
displaying information to the screen.

• Rectangle: indicates a process, such as


assigning a value to a variable or performing
some mathematical operation.

• Diamond: indicates a decision, where the


answer is typically “yes/no” or “true/false”.
Each arrow leading out of a diamond should
be labeled with the result of the decision.
Example of a Flowchart
This flowchart shows how to add two
values together and print their sum.

Remember ...

◦ Terminator are ovals


◦ Input/Output are parallelograms
◦ Processes are rectangles
◦ Diamonds are decisions (but there are
none here)
Another Example of
a Flowchart
This flowchart adds inputted values
until -1 is entered.

Remember ...

◦ Terminator are ovals


◦ Input/Output are parallelograms
◦ Processes are rectangles
◦ Diamonds are decisions
You Try!
Consider the problem of determining the largest of
three numbers. Create a flowchart
that illustrates the algorithm.
Algorithms
 To successfully solve a problem, it is necessary to
establish a set of rules that will allow us to find the
solution. In computer science and in mathematics, the
term for this is an algorithm.

 A more precise definition of an algorithm would be


something like this:
Example of an Algorithm
We use algorithms every day. Take, for example, the following
algorithm for making scrambled eggs. Your method of making
scrambled eggs may be different from the one below.

• Turn on the heat on the stove.


• Place a pan on the burner.
• Put a spoonful of butter in the pan. Each step is clearly
• Crack an egg into a bowl. defined, and well-
• Whisk the egg until it is scrambled. ordered.
• Pour the scrambled egg into the heated pan. All recipes are
• Stir the egg until it is cooked. analogous to
• Turn off the heat. algorithms, in this
• Remove the pan from the burner. sense.
• Transfer the egg to a plate.
• Enjoy breakfast.
Algorithms – Some Videos
Video:
How to Cook Beef Stroganoff (and Fight Off a Ninja)

Video:
Honda: The Cog

Video:
The Page Turner

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy