Introduction to C Programming ET2560 Introduction to C Programming Introduction to C Programming Unit 1, Part 2 Unit 1 Presentations
Flowchart Elements Unit 1: Algorithms
Begin and End Shapes These shapes are used to begin and end a flowchart The beginning shape has the algorithm name as its label The end shape contains the word “End”
Rectangle Shape – Actions Rectangle has one entry and one exit The text in the rectangle is pseudo-code corresponding to one step in the algorithm
Diamond Shape – Decision Point One entry, two exits (one for “yes”, the other for “no”) Contains one question, with yes/no answer
Selection Shape Selection is an extension of the decision point Instead of a question, the diamond contains a value The value selects which branch to take One “other” branch is used for all other values that don’t have a branch
Connector Shape – On-page Use for a connection on same page Shape shows connection from one point to another Left shape can be used multiple times Right shape, used once, shows the destination of connection
Connector Shape – Off-page Use for a flowchart larger than one page Shape shows connection from one page to another Left shape can be used multiple times Right shape, used once, shows the destination of connection Visio automatically creates a new page when this shape used
Shapes Combine to Create Structures Straight-line structure Single-sided branch Double-sided branch Selection structure Until loop While loop Do-while loop
Straight-line Structure
Single-sided Branch
Double-sided Branch
Selection Structure Selection structure is an extension of the branch All branches must converge together at the end
“Do-While” Loop
“While” Loop
“Until” Loop
Flowchart Examples Unit 1: Algorithms
Flowchart Example – Count to 9 Here is an algorithm, in pseudo code, to output 1-9: Output “List of Numbers less than 10” Put 1 in number Output number Add 1 to number If number is less than 10, go back to step 3 End
Flowchart Created from Algorithm
Flowchart Example – Odd #s < 10 Output “List of Odd Numbers less than 10” Put 1 in number If number divided by 2 has remainder 0, go to step 5 Output number Add 1 to number If number is less than 10, go back to step 3 End
Flowchart for Odd Numbers < 10