You want to display a vertical message consisting of graphic block letters (made from stars) on the screen, such as:
* * *** * * --- *** * * *** * * *** * * --- *** * * ***
Notice the redundant (repetitious) use of some of the lines of text above. For example, the block letter "H" is used twice. So is the letter "O". The single line containing the hyphens ("---") is also used twice. If we deal with each block letter and the line of hyphens as separate problems, we can minimize the need for highly repetitive coding later in the programming process.
Almost any task can be sub-divided into smaller, simpler tasks called "modules". Such an approach is called top-down design. Each module is treated as a separate problem. In the C++ programming language, modules are written in separate blocks of code called functions, with a master function named "main" that calls (loads and executes) the other functions in whatever order is necessary to produce the overall objectives of the program.
Most problems can be organized (or "structured") in a variety of different ways. For example:
* *" or "***"). Finally, we would write a main function that would call the other functions in the proper order to produce the overall objectives of the program. When making a decision about how to structure a problem, you should consider how its separate functions might be used in future programs. In this example, you would probably find that a group of functions that display entire block letters would be more useful than a group of functions that display lines of stars in various patterns. Thus, the first bulleted approach above would be the more useful.
An analyst's approach to top-down design can be illustrated in a form of documentation known as a structure diagram. The structure diagram below illustrates the first of the bulleted top-down design approaches above. The diagram starts with a general task which is labeled and described in a box at the top, followed by more detailed descriptions on the levels below.

Notice that each function appears in a box with a unique function identifier (label) at the top and a brief description of its purpose below. The description of purpose need not be as detailed as a problem statement, but must provide enough detail to identify the purpose of the function. Although each of the sub-tasks may be called more than once by the main function (HOHO), each separate function is shown only once in the structure diagram. Then, each function will be analyzed as a separate (simpler) program and documented accordingly.
When separate functions are used, you should provide separate documentation for each function. This includes a Problem Statement, Data Definition (Sample Outputs, Symbolic Constant Lists, Variable Lists, etc.) and an Algorithm or Flowchart for each function. The Desk Check is performed independently for each function and then overall for the main function.
The remainder of the documentation for this overall problem and its functions appears below.
Display the message "HO HO" as a totem pole of block letters (as shown in the Sample Softcopy below) constructed from stars (asterisks) and spaces, 3 lines high by 3 characters wide. Separate each letter in the words of the output with a line of 3 hyphens. Separate each word in the output with a blank line.
In the sample output below, the numbers to the left of the sample screen are there only for your reference in other documentation. They are not intended to be part of the output.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
* * *** * * --- *** * * *** * * *** * * --- *** * * *** |
(None)
(None)
The desk check cannot be performed until all subordinate functions have been completed. Each function should be checked independently and then an overall check can be performed.
Display the block letter "H" constructed from stars and spaces, 3 lines high by 3 characters wide.
1 2 3 |
* * *** * * |
(None)
(None)
Since this function involves no variables, there is no need for a Tracing Chart.
TEST OUTPUT:
1 2 3 |
* * *** * * |
Display the block letter "O" constructed from stars and spaces, 3 lines high by 3 characters wide.
1 2 3 |
*** * * *** |
(None)
(None)
Since this procedure involves no variables, there is no need for a Tracing Chart.
TEST OUTPUT:
1 2 3 |
*** * * *** |
Display a line of 3 hyphens.
1 |
--- |
(None)
(None)
Since this procedure involves no variables, there is no need for a Tracing Chart.
TEST OUTPUT:
1 |
--- |
(None)
(None)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
* * *** * * --- *** * * *** * * *** * * --- *** * * *** |
// hoho.cpp - A program to display a totem message "HO HO"
// Written by: Randy Gibson - Date: 11/13/2011
#include <iostream> // load pre-defined code for console I/O
using namespace std; // to define context for cin and cout
// ----- FUNCTION PROTOTYPES ------------------------------
/* Function prototypes are statements that declare the labels
used to name functions prior to using them in the code below */
void BlockH (); // Display the block letter H
void BlockO (); // Display the block letter O
void Hyphens (); // Display a line of 3 hyphens
// ----- PROGRAM SETUP ----- CONSTANTS & VARIABLES -------
// Note: this program has neither constants nor variables./
// ===== MAINLINE CONTROL ================================
int main ()
{
BlockH(); // Call the function without arguments
Hyphens(); // Call the function without arguments
BlockO(); // Call the function without arguments
cout << endl;
BlockH(); // Call the function without arguments
Hyphens(); // Call the function without arguments
BlockO(); // Call the function without arguments
return 0; // Return zero error code to parent process
}
// ===== CHILD FUNCTIONS ================================
// ----- DISPLAY BLOCK LETTER H --------------------------
void BlockH ()
{
cout << "* *\n";
cout << "***\n";
cout << "* *\n";
}
// ----- DISPLAY BLOCK LETTER O --------------------------
void BlockO ()
{
cout << "***\n";
cout << "* *\n";
cout << "***\n";
}
// ----- DISPLAY LINE OF 3 HYPHENS -----------------------
void Hyphens ()
{
cout << "---\n";
}