The universal flow chart
The top-level view of a program or a function often matches the universal flowchart.
Frequently, a problem is composed of pieces that can be processed in sequence. The first task in designing a program is to decide what the pieces are and how to iterate over them.
Here is an easy example:
Problem: You have a null-terminated string defined in main()
.
You wish to output the characters to the monitor, but
you want each output alphabetic character to be a capital letter.
Here is an example string literal:
char sample = "But, soft! what light through yonder window breaks?"
which should be output as:
BUT, SOFT! WHAT LIGHT THROUGH YONDER WINDOW BREAKS?
To match this to the universal flowchart you need to break the problem into pieces. The program looks something like this:
#include <stdio.h> void main( void ) { int ch; /* current char. putchar expects an int */ int j; /* index to current char */ char sample[] = "But, soft! what light through yonder window breaks?"; /* output the characters */ }
What are the pieces of this problem?