




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Study Guide on flowcharting Material Type: Notes; Professor: Ohanehi; Class: Engineering Exploration; Subject: Engineering Education; University: Virginia Polytechnic Institute And State University; Term: Fall 2008;
Typology: Study notes
1 / 8
This page cannot be seen from the preview
Don't miss anything!





Virginia Polytechnic Institute and State University Copyright J.C. Malzahn Kampe, 1999-
Much like an outline serves as a guide in the preparation of a major paper or report, a flowchart maps the logic used in programming a computer to solve a problem. For the experienced programmer, a flowchart is extremely helpful when the required logic paths become complex. It serves as a “picture” of the approach used to solve the problem and as archival documentation of the corresponding computer program. Flowcharts are also useful to the novice programmer as a means of developing and documenting problem solving approaches that are then easily converted to computer programs. Because programming languages vary in syntax (i.e., the way in which commands are typed) and in computing environment (e.g., procedural versus object-oriented or descriptive languages), instruction on the language you are to use is left to your professor. The balance of this document will focus on the preparation for programming – that is, flowcharting. Foremost, flowcharts are intended to be visual aids. As such, their presentation must follow certain guidelines. These guidelines are outlined in the following sections. The first deals with the symbols used in flowcharting. It is important to keep track of the appropriate symbol shape associated with the kind of operation you intend to have executed. In this regard, it may help to think of traffic signs. We all expect “STOP” signs to have an octagonal shape, railroad crossings to be marked with an “X”, and pertinent road information to be conveyed via diamond shaped signs. In flowcharting, the restricted use of a symbol adds to the visual utility of flowcharts because the human eye is easily trained to recognize a shape, and the brain to associate that shape with specific meaning. Included in the list of flowcharting symbols is the hexagon, used to designate a loop, or repetition, in the solution algorithm. Often this symbol is omitted in efforts to make flowcharting as generic as possible. We include this looping symbol, however, for at least three reasons. First, its use usually maintains a one-to-one correspondence between flowcharting symbol and programming statement when converting a solution algorithm from a flowchart to a computer program. Secondly, use of the looping hexagon adds a semblance of order to the flowcharting of repetitions, especially when adherence to the guidelines for entrance and exit lines is maintained. This is beneficial to novice programmers. The third, and perhaps most important, reason for the use of the hexagon and corresponding entrance/exit rules is the visual clarity in the completed flowchart. A flowchart should serve as a picture of the logic used to solve a problem. Following the list of flowcharting symbols, some basic line rules, the entrance/exit line rules for each symbol, and general flowcharting rules are presented. An example problem and its solution then show how these rules should be implemented. When preparing flowcharts, keep in mind that any symbols used to convey information or indicate mathematical operations must be generic; no syntax (characters specific to a programming language) is used. This language independence will maintain the archival value of your flowchart, as well as its adaptability to any programming language.
Virginia Polytechnic Institute and State University Copyright J.C. Malzahn Kampe, 1999, 2000, 2001, 2002
Terminator Terminators are used to begin (START) or end (Start or Stop) (STOP) logic flow. Note the shape of this symbol; it is not oval.
Input / Output Indicate INPUT or OUTPUT within the symbol and, below, the variable names that store the values.
Process Process blocks generally contain a single value assignment statement: one variable left of “ = ”; all variables right of “ = ” have numeric values. Note that characters specific to a programming language (i.e., syntax) should not be used.
Test / Decision Decision diamonds contain “test” conditions that “Selection” select the subsequent logic flow path. Always label the two exit lines (TRUE or FALSE); see Entrance/Exit line rules.
Loop / Repetition The hexagon contains conditions that must be met in order for the loop logic sequence to execute; see Entrance/Exit line rules.
On-Page Connector A connector contains a number to indicate the matching connector. Circles are used when the two matching connectors are on the same page.
Off-Page Connector These connectors also contain numbers to indicate the matching set. The small pentagon is used when the two matching connectors are on different pages. Node Nodes are used to connect converging logic flow lines when arrow heads would otherwise meet.
R, theta
if N > 10
while y <
Area = 2 · pi · r · L
Virginia Polytechnic Institute and State University Copyright J.C. Malzahn Kampe, 1999, 2000, 2001, 2002
“STOP” – one line in
alpha
Test Condition
TRUE
FALSE
(“IN” from prior portion of the flowchart)
Test Condition
TRUE
FALSE
Virginia Polytechnic Institute and State University Copyright J.C. Malzahn Kampe, 1999, 2000, 2001, 2002
Looping Conditions
(“IN” from prior portion of flowchart) (“IN” for Loop Return) (^) (“OUT” for Looping Conditions not met – “EXIT” the loop)
(“OUT” for Looping Conditions met – “ENTER” the loop logic sequence)
Virginia Polytechnic Institute and State University Copyright J.C. Malzahn Kampe, 1999, 2000, 2001, 2002
There are some things to note in the solution flowchart for the example problem. First is the process block just below the “START” terminator. This block initializes the variables used in the problem; that is, it gives the variables initial values. This step is often done as a precautionary measure to ensure that each variable has a value in the event that a value assignment statement is inadvertently omitted. Sometimes, however, initialization of a variable is required for the logic of the solution, as with the counter variable N in the example. When variables are initialized, the value assignment statements that accomplish initialization are often grouped together in the same processing rectangle to emphasize that initialization of variables is generally considered a “single step” in the solution algorithm. Other than for initialization, each value assignment statement in an algorithm warrants a separate process block. Another item to note is the reference to “J” in the loop hexagon. Here “J” is called the loop variable, and it is allowed to run from 1 to 10, inclusive, incrementing by 1 each time the loop symbol is entered. “J” does not appear anywhere else in the flowchart, so its only function in this example is to control how many times the loop logic sequence is repeated. The value of a loop variable must never be altered by a value assignment statement within the loop (i.e., the loop variable is never placed on the left of “=” within the loop). But, the loop variable may be used on the right side of “=” in value assignment statements within the loop. For example, suppose our problem had been to examine a set of circles with radii from 4 to 22 inches, incrementing by 2 inches. The statement in the loop hexagon might then have been “for R from 4 through 22 by 2” and the input of R within the loop would have been omitted. A last point that deserves some attention is the position of the output symbols. Output position is not a trivial matter, and it does not necessarily only precede the end of logic flow. In the example, output is required for each circle that has an area greater than 20. In the given flowchart, this requirement means that an output operation must occur inside the loop for those circles that meet the area criterion. On the other hand, only the total number of circles not meeting that criterion is requested, and the output of N can thus be placed outside of, and subsequent to, the loop.
Virginia Polytechnic Institute and State University Copyright J.C. Malzahn Kampe, 1999, 2000, 2001, 2002
Draw a flowchart that describes an algorithm which calculates the area and circumference of ten circles, allowing circle radius as an input variable, and outputs the radius, area, and circumference of those circles for which area is greater than 20. The number of circles for which area is equal to or less than 20 should also be output.
for J from 1 through 10 by 1
AREA = pi · R^2
pi = arccos (-1)
if AREA > 20
True
False
CIRC = 2 · pi · R