Flowcharts
• Remember that a solution to a problem is called an algorithm.
• Algorithms are often a series of
steps required to solve the problem.
• A flowchart is a graphical representation of an algorithm.
• Each step in the algorithm is represented by a different symbol
Used to indicate a predefined or user-defined function is called
Flowchart Symbols
Start
InputNumOne
InputNumThree
Input NumTwo
Calculate totalof 3 numbers
Output the total
Stop
Sequential StructureFlowchartExample
Create a program that will allow the user to input 3 integers and have the sum calculated and outputted.
Looping StructureFlowchart Example #1 – while loop
Create a program that will have the user input a name and have it outputted until the user wishes to finish.
Start
While:
Input a name
Input continue?
Output a name
True
False
Stop
Start
Initializetotal to 0
Initializei to 0
If i=10
Add numberto total
Incrementi
Stop
Input a number
No
Outputtotal
Yes
Looping StructureFlowchart Example #2 - for loopCreate a program that will allow the user to input 10 integers and have the sum calculated and outputted. Use a loop for this program.
Selective StructureFlowchart #1 - BinarySelection Structure
Create a program that will allow the user to input their age. If they are over 16, output they can drive, otherwise output they can’t drive.
Start
Input age
if age >=16True
Output“Drive”
Output“Can’t”
False
Stop
Selective StructureFlowchart #2 - Multiple Selection Structure
Create a program that will allow the user to input the number of widgets they sold. The program will output their level based on the following scale:
• Over 500, they are in the “Gold Club”
• Over 300, they are in the “Silver Club”
• Over 100, they are in the “Bronze Club”
• Not over 100, they are in the “Get a New Job Club”
If sales >500
Start
Input sales
If sales >300
False
If sales>100
False
Output“New Job”
False
True
Output“Gold”
Stop
Output“Silver”
True
Output“Bronze”
True
Selective StructureFlowchart #2 Multiple Selection Structure (cont.)
Start
Input astring
Count Characters
In string
Count spaces
in string
Add 1 to numberof spaces
Calculate averagenumber of characters
in the words
Output average number
of words
Stop
Create a program that will allow the user to input a string of more than one word. It will calculate and output the average number of characters in the words.
Flowchart for a ProgramUsing PredefinedFunctions
Flowchart Assignment Draw a flowchart for each of the following problems•Sequential #4•Selective #1, #3, #6•Repetitive #1b, #3b, #7•Functions #5, #6•Files #2