Logic Flowchart

In writing a program in any language, considerable thought and planning should proceed the actual coding. Logic flowcharts can be a valuable part of developing the programming logic. For the simple programs that we study at the beginning of this course, the value of the logic flowchart is clearly questionable, but for complex programs it is a great tool.

In writing the logic flowchart, you lay out a flowchart segment for each paragraph or module in the program. In the flowchart that accompanies SAMPLE1, there is a flowchart segment for the MAIN-PROGRAM paragraph as well as all of the other paragraphs in the program. I have labeled the paragraphs with their COBOL names, but frequently the names are practical names that convey the purpose of the module.

Flowcharting symbol         Explanation        
This symbol is used to indicate processing that needs to be done - setting up a line, doing a calculation, opening files, closing files etc.

This symbol is used to indicate that a paragraph is to be performed and then control will return to the next sequential command. The double lines indicate perform.

This symbol indicates the beginning or end of a module or paragraph.

This symbol indicates input/output - specifically the reading of a record from a file, the writing of a record on a file, or the writing of a line on a printed report.

This symbol indicates a condition - usually the branch to the right means YES and the branch to the left or down indicates.

This symbol is used to branch when the bottom of the page has been reached - it is also used as an entry point to branch to.


In the flowcharting example illustrated here, the first module is MAIN-PROGRAM which controls the program. MAIN-PROGRAM executes the paragraph that handles initialization, the paragraph that handles processing and the paragraph that handles termination before finally encountering the stop run.


This paragraph or routine simply opens the files. When the file opening has been accomplished, control returns to MAIN-PROGRAM.


This paragraph or routine does the initializing READ and if end of file occurs, changes the value of the END-OF-FILE indicator from NO to YES. It then checks to make sure that the END-OF-FILE indicator has not been set to NO and if it hasn't performs the processing paragraph (B-200-PROCESS-RECORD). When B-200-PROCESS-RECORD is complete, control returns and the END-OF-FILE indicator is checked again. This is a repetitive loop that is executed over and over again until finally the END-OF-FILE indicator is YES indicating that end of file has been reached. At that point, the paragraph is complete and control returns to MAIN-PROGRAM.


In this paragraph or routine, the line is set up and written. Then the next record in the file is read. If end of file is encountered, the END-OF-FILE indicator gets changed from the original value of NO to YES. When the paragraph is complete, control is returned to B-100-PROCESS-FILE.


In this paragraph or routine, the files are closed and then control returns to the MAIN-PROGRAM.


The whole flowchart is illustrated below. This flowchart applies to the initial program being discussed in class - Sample1.