//Devin Scheu CS1A Chapter 5, P. 297, #22
//
/**************************************************************
*
* DISPLAY A SQUARE OF X CHARACTERS
* ____________________________________________________________
* This program creates a square pattern using X characters
* based on a positive integer side length.
*
* Computation is based on nested loops to print X characters
* for each row and column
* ____________________________________________________________
* INPUT
* sideLength : The length of each side of the square
*
* OUTPUT
* squarePattern : The square pattern of X characters
*
**************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
//Variable Declarations
int sideLength; //INPUT - The length of each side of the square
string squarePattern; //OUTPUT - The square pattern of X characters
//Prompt for Input
cout << "Enter a positive integer no greater than 15: \n";
cin >> sideLength;
//Input Validation
while (sideLength < 1 || sideLength > 15) {
cout << "\nError: Please enter a number between 1 and 15: \n";
cin >> sideLength;
}
//Display Square Pattern
for (int row = 0; row < sideLength; row++) {
for (int col = 0; col < sideLength; col++) {
cout << "X";
}
cout << endl;
}
return 0;
} //end of main()