1: //sayhi3.cpp 2: //Displays a greeting to three particular individuals, using their 3: //initials, and positioned at various places on the output line. 5: #include <iostream> 6: #include <iomanip> 7: using namespace std; 10: void DescribeProgram(); 11: void DisplayGreeting(int column, char firstChar, char lastChar); 14: int main() 15: { 16: DescribeProgram(); 18: DisplayGreeting(12, 'J', 'C'); 19: DisplayGreeting(1, 'P', 'S'); 20: DisplayGreeting(68, 'A', 'F'); 21: cout << endl; 22: } 25: void DescribeProgram() 26: //Pre: The cursor is at the left margin. 27: //Post: The program description has been displayed, 28: // preceded and followed by at least one blank line. 29: { 30: cout << "\nThis program displays a greeting to three individuals, " 31: "using their\ninitials, and positioned at various locations on " 32: "the output line.\n\n"; 33: } 36: void DisplayGreeting(/* in */ int column, 37: /* in */ char firstChar, 38: /* in */ char lastChar) 39: //Pre: "column", "firstChar" and "lastChar" have been initialized, with 40: // 1<=column<=68, 'A'<=firstChar<='Z', and 'A'<=lastChar<='Z'. 41: //Post: A greeting has been displayed, using the initials in 42: // "firstChar" and "lastChar", starting in position "column", 43: // and preceded and followed by at least one blank line. 44: { 45: cout << endl; 46: cout << setw(column-1) << "" 47: << "Hi there, " << firstChar << lastChar << "!\n"; 48: }