// Program takes as input an integer between 1 and 20 // and prints a hollow square made up of * and blanks // of the specified size // Exercise 2.28 from D&D #include main () { int size, col, row; // initialize size=0; // input square size -- make sure it is in bounds while (size < 1 || size > 20) { cout << "Input size of square (a number between 1 and 20): "; cin >> size; } cout << endl; // print top of square for (col = 1; col <= size; col++) cout << "*"; cout << endl; // print internal square lines for (row = 2; row <= size - 1; row++) { cout << "*"; for (col = 2; col <= size - 1; col++) cout << " "; cout << "*"; cout << endl; } // print bottom of square for (col = 1; col <= size; col++) cout << "*"; cout << endl; return 0; }