#include using namespace std; void PrintLine (int numstars) // pre: numstars > 0 // post: displays numstars stars in one line { int i; for (i=1; i <= numstars; i++) { cout << "*"; } cout << endl; // end of line marker is put to the end of the line } void DrawRectangle (int height, int width) // pre: height and width > 0 // post: displays a rectangle of stars with height lines and width columns { int i, j; for (i=1; i <= height; i++) { for (j=1; j <= width; j++) // inner loop prints one line of stars { cout << "*"; } cout << endl; // end of line marker is put to the end of each line } } void DrawRectangle_with_Function (int height, int width) // pre: height and width > 0 // post: displays a rectangle of stars with height lines and width columns { int i; for (i=1; i <= height; i++) { PrintLine(width); } } void DrawTriangle (int side) // pre: side > 0 // post: displays a perpendicular isosceles triangle with side amount of stars at each perpendicular side { int i, j; for (i=1; i <= side; i++) { // inner loop can be replaced with this call // PrintLine(i); for (j=1; j <= i; j++) // inner loop prints one line of stars { cout << "*"; } cout << endl; // end of line marker is put to the end of each line } } int main() { int a, b; cout << "Please enter height and width of the rectangle: "; cin >> a >> b; DrawRectangle(a, b); cout << endl; DrawRectangle_with_Function(a, b); cout << endl; cout << "Please enter the length of the perpendicular side of the isosceles rectangle: "; cin >> a; DrawTriangle(a); return 0; }