Professional Documents
Culture Documents
STRUCTURES
Spaghetti Code
A slang term used to refer to a tangled programming
source code
Memory Leaks
Memory leaks will not only slow a program down, but
also cause it to crash.
Structured Programming
A Structure is a basic unit of programming logic; each structure is one of the
following:
Sequence
Selection
Loop/Repetition/Iteration
Attaching structures
end to end is called
stacking structures.
Combining Structures
You can have a sequence of
three tasks on one branch of
a selection, as shown in the
figure. Placing a structure
within another structure is
called nesting structures.
Clarity - As programs get bigger, they get more confusing if they are not structured.
Professionalism - Make your programs to be structured. It is the way things are done
professionally like all other programmers do.
Efficiency - Most newer computer languages support structure and use syntax that lets
you deal efficiently with sequence, selection, and looping. Newer languages such as
C#, C++, and Java enforce structure by their syntax.
Maintenance - Its easier to modify and maintain structured programs as changes are
required in the future.
Modularity - Structured programs can be easily broken down into modules that can be
assigned to any number of programmers. The routines are then pieced back together
like modular furniture at each routine’s single entry or exit point
Board Work:
Create a flowchart that will accept a number
ranging from 1 to 100. If the input is higher than
100 it will print “Condition Exceeded” and it will
ask for input again. If the input is less than 50 it
will print “Result 1”. If the input is higher than 50
it will print “Result 2”.
Start
int number
input number
YES num>
NO
100
“Condition YES NO
Exceeded” num
>50
“Result 1” “Result 2”
End