Nassi-Schneiderman Flowcharts
For programming, it is important to organize your
thoughts so that you can organize your instructions. If a program is designed well, then it is easier to code it,
modify it, and it is easier to read and understand it. Structured programming is a concept that
helps us to design better computer programs, and it is realized through a
design technique called flowcharting, which is used to determine how a
computer program will proceed, once it is running on a computer. Structured programming helps us to design
better computer programs by giving more structure to your own thought process
when solving a problem. Ultimately,
there are only three basic structures necessary to develop a program:
1.
The
sequence structure, which is used for simple instructions
2.
The
decision structure, which allows us to design actions in which a choice is
made.
3.
The
loop (iterative) structure, which allows us to design repetitive actions.
Many flowcharting techniques exist to design
computer programs, but this document focuses on the design of programs using
Nassi-Schneidermann (NS) flowcharts.
These charts are graphically oriented in the sense that each of the
above structures is given a basic geometric shape. There are several rules for creating NS flowcharts:
1.
An
NS chart is always rectangular. The
width is not significant, except for the fact that when two charts are
combined, they must be the same width.
2.
The start of an NS chart is always at the
top.
3.
Progress
through a chart is always from top to bottom, except at the lower limit of a
loop structure (the L-shaped frames).
If the end of a loop is reached but no exit condition has been
satisfied, then progress resumes at the top of the same loop box. Loops may be exited only at the horizontal
bar of the L-shaped frame.
4.
Vertical
lines are never crossed
5.
A
rectangle may be exited at any given time in one direction only, at the
bottom. If a rectangle contains
decision triangles, then it must be exited in the direction of the rectangle
directly under the currently appropriate decision outcome.
6.
Any
rectangle that contains no other lines is either a single (possibly empty)
action or another NS chart.
The Sequence Structure
The sequence structure is
used for a simple instruction.
Pictorially, the sequence structure looks like this:

Example 1:
The first example assigns
the value 10 to a variable called NUM:
![]() |
To code this in C or C++,
you’d type the following into a program:
NUM = 10;
The second example obtains
the value of the variable AGE from the user (the person sitting at the
keyboard):

To code it in C or C++,
you’d type the following into a program:
cin << age;
The third example
prints/outputs the current value of the variable SUM (it will be printed to the screen):

To code it in C or C++, you’d type the following
into a program:
cout
>> sum;
Example 2:
The following NS chart prints the sale price of an
item that is the summation of its price and the tax. This assumes that the item is being purchased in Michigan, which
has a 6% tax rate. Notice that logical
flow is very simple here: the program
progresses from one rectangle to the one immediately below it:
