//Brandon West CSC5 Chapter 5, p. 298,#22
/*************************************************************************
*
* SQUARE DISPLAY OUTPUT
* _______________________________________________________________________
* This program asks user to enter positive integer no greater than 15,
* then displays a square on the screen using character 'X'. The number
* entered by user is the length of each side of the square.
* _______________________________________________________________________
*INPUT
* sideLength : Store user side length input
*
*OUTPUT
* row : Track number of rows
* col : Tracks number of columns
*
************************************************************************/
#include <iostream>
using namespace std;
int main(){
int sideLength; //User input side length
int row; //Counter for output rows
int col; //Counter for output columns
//Get side length
cout << "\nEnter positive number no greater than 15: \n";
cin >> sideLength;
//Validate side length is 1 - 15
while (sideLength < 1 || sideLength > 15){
cout << "\nEnter positive number between 1 - 15: \n";
cin >> sideLength;
}
if (sideLength >= 1 && sideLength <= 15){
//Built row
for (row = 1; row <= sideLength; row++)
{
//Build column
for (col = 1; col <= sideLength; col++){
cout << "X";
}
cout << endl;
}
}
return 0;
}