#include <iostream>
//Andres Guzman CSC5 Chapter 5, P. 298, #22
//
/*******************************************************************************
*
* DISPLAY A SQUARE
* ______________________________________________________________________________
* This program will display a square of X
*
* Computation:
*
* Input Validation: num < 1 || num > max
* Dimensions: row/col < num
* ______________________________________________________________________________
* INPUT
*
* num = Allows user to input a value into the program
* OUTPUT
*
* X = Character used to display the shape of the square
*
*******************************************************************************/
#include <iostream>
using namespace std;
int main ()
{
int max = 15; //Max number allowed to be input
int num; //Allows user to input a value into the variable
//
//Display input prompt
cout << "Enter a number no greater than 15: ";
cin >> num;
cout << endl;
//
//Initializing While Loop
while (num < 1 || num > max) //Limits the range of inputs between 1 & 15
{
cout << "\nInvalid number, please try again.\n";
cout << "\nEnter a number no greater than 15: ";
cin >> num;
}
//
//Initialzing For Loop
for (int row = 0 ;row < num;row++) //Outputs the row of characters
{
//
//Nesting For Loop Inside For loop
for (int col = 0 ;col < num; col++) //Outputs the column of characters
{
cout << "X";
}
cout << endl;
}
return 0;
}