The C++ Programming Language 657
BD2
17:
18: cout << “\nrectangle( );\n”;
19: rectangle( );
20:
21: return 0;
22: }
23:
24: void rectangle ( int width, int length, char draw_char )
25: {
26: int ctr1 = 0;
27: int ctr2 = 0;
28:
29: for (ctr1 = 0; ctr1 < length; ctr1++ )
30: {
31: cout << “\n”;
32: for ( ctr2 = 0; ctr2 < width; ctr2++)
33: {
34: cout << draw_char;
35: }
36: }
37: cout << “\n”;
38: }
rectangle( 8, 2, ‘*’ );
********
********
rectangle( 4, 5 );
XXXX
XXXX
XXXX
XXXX
XXXX
rectangle( 2 );
XX
XX
XX
rectangle( );
XXX
XXX
XXX
LISTINGB2.5 continued
OUTPUT
37 448201x-Bonus2 8/13/02 11:18 AM Page 657