Numbering System TODAY AND TOMORROW 11th Edition Understanding Computers, 11th Edition 1
What is a “Flow Chart?” a visual tool that helps you understand the flow of your program You can think of flow charts as pipes of water: You pour water in the top. Water pours through the pipes and is pulled downward Chapter 7 Understanding Computers, 11th Edition
Flowchart Based Design Chapter 7 Understanding Computers, 11th Edition
Flow Chart Basics 1 Diamonds (decision symbol) contain conditions Rectangles represent statements of work. For example: printf() flow line Chapter 7 Understanding Computers, 11th Edition
Flow Chart Basics 2 Connector symbol grade >=65 true print “passed” false Chapter 7 Understanding Computers, 11th Edition
if/else Flow Chart True False grade >=65 Print “You failed” True False grade >=65 Print “You failed” Print “You passed” Chapter 7 Understanding Computers, 11th Edition
Flowcharts Represent flow of control of algorithms: sequences selection iteration Useful for: Finding semantic errors Determining test data set Use of Flowcharts Pseudo-code flowchart Flowchart code Chapter 7 Understanding Computers, 11th Edition
Represented by concatenating instructions (usually vertically) Flowchart: Sequence Represented by concatenating instructions (usually vertically) Instruction in rectangular box Step A: input number Step B: add 1 to number Order of execution indicated by arrows Step C: output number Chapter 7 Understanding Computers, 11th Edition
Sequence (cont) Example 2: Step A: input number an algorithm involving “selection” Step A: input number Step C: output number Example 2: Step A: input number Step B: if number is negative, then add -1 to number else add 1 to number Step C: output number Chapter 7 Understanding Computers, 11th Edition
Flowchart: Selection Step A C1 true? S2 Step C S1 YES NO Arrow labeled with result of condition test Condition test in diamond Step A C1 true? S2 Step C S1 Step A if ( condition C1 ) { <sequence S1> } else <sequence S2> Step C YES NO Chapter 7 Understanding Computers, 11th Edition
Example: Algorithm to Flowchart input number is number negative? add -1 to number YES NO add 1 to number output number input number if number is negative, then add -1 to number else add 1 to number output number Chapter 7 Understanding Computers, 11th Edition