# Programming Fundamentals/Flowcharts
## Overview

A flowchart is a type of diagram that represents an algorithm, workflow or process. The flowchart shows the steps as boxes of various kinds, and their order by connecting the boxes with arrows. This diagrammatic representation illustrates a solution model to a given problem. Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields.

## Discussion

Flowcharts display the steps in code as shapes connected together with arrows. The main goal is to create a rough draft of a solution to a coding problem. The type of shapes seen in the flowchart depends on what statements the programmer wants to create. For example, an “if” statement (a part of the code that only works if a certain condition is true) is represented by a diamond, while the looping statements (ones that allow a section of code to repeat itself as needed) are represented by hexagons. Flowcharts may also color code the different types of statements as well, making the code easier to read.
Common flowcharting symbols and examples follow. When first reading this section, focus on the simple symbols and examples. Return to this section in later chapters to review the advanced symbols and examples.

### Simple Flowcharting Symbols
#### Terminal

The rounded rectangles, or terminal points, indicate the flowchart's starting and ending points.

#### Flow Lines

Note: The default flow is left to right and top to bottom (the same way you read English). To save time arrowheads are often only drawn when the flow lines go contrary the normal.

#### Input/Output

The parallelograms designate input or output operations.

#### Process

The rectangle depicts a process such as a mathematical computation, or a variable assignment.

#### Decision

The diamond is used to represent the true/false statement being tested in a decision symbol.

### Advanced Flowcharting Symbols
#### Module Call

A program module is represented in a flowchart by a rectangle with some lines to distinguish it from process symbol. Often programmers will make a distinction between program control and specific task modules or between local functions and library functions.

#### Connectors

Sometimes a flowchart is broken into two or more smaller flowcharts. This is usually done when a flowchart does not fit on a single page, or must be divided into sections. A connector symbol, which is a small circle with a letter or number inside it, allows you to connect two flowcharts on the same page. A connector symbol that looks like a pocket on a shirt, allows you to connect to a flowchart on a different page.

### Simple Examples

We will demonstrate various flowcharting items by showing the flowchart for some pseudocode.

#### Functions

pseudocode: Function with no parameter passing
pseudocode: Function main calling the clear monitor function

#### Sequence Control Structures

The next item is pseudocode for a simple temperature conversion program. This demonstrates the use of both the on-page and off-page connectors. It also illustrates the sequence control structure where nothing unusual happens. Just do one instruction after another in the sequence listed.
pseudocode: Sequence control structure

### Advanced Examples
#### Selection Control Structures

pseudocode: If then Else
pseudocode: Case

#### Iteration (Repetition) Control Structures

pseudocode: While
pseudocode: For
The for loop does not have a standard flowcharting method and you will find it done in different ways. The for loop as a counting loop can be flowcharted similar to the while loop as a counting loop.
pseudocode: Do While
pseudocode: Repeat Until

## Key Terms
### decision symbol

    A diamond used in flowcharting for asking a question and making a decision.

### flow lines

    Lines (sometimes with arrows) that connect the various flowcharting symbols.

### flowcharting

    A programming design tool that uses graphical elements to visually depict the flow of logic within a function.

### input/output symbol

    A parallelogram used in flowcharting for input/output interactions.

### process symbol

    A rectangle used in flowcharting for normal processes such as assignment.

## References

* cnx.org: Programming Fundamentals – A Modular Structured Approach using C++
* ↑ Wikipedia: Flowchart