fork download
  1. //Matthew Santos CS1A Ch. 5, Pg. 298, #22
  2. /***********************************************
  3.  *
  4.  * DISPLAYS CUSTOM SQUARE
  5.  * _____________________________________________
  6.  * Displays a square with the dimensions inputted.
  7.  * Number must be a positive integer 1-15.
  8.  * _____________________________________________
  9.  * INPUT
  10.  * size : size of the square
  11.  *
  12.  * OUTPUT
  13.  * custom made square
  14.  ***********************************************/
  15. #include <iostream>
  16. using namespace std;
  17.  
  18. int main() {
  19.  
  20. //Initialize
  21. int size;
  22.  
  23. //Get size
  24. cin >> size;
  25.  
  26. //Displays square
  27. if (size >= 0 && size < 15)
  28. for (int row = 0; row < size; row++) {
  29. for (int col = 0; col < size; col++) {
  30. cout << "X";
  31. }
  32. cout << endl;
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5316KB
stdin
2
stdout
XX
XX