fork download
  1. //ANDREW ALSPAUGH CS1A CHAPTER 5. P. 298 # 22
  2. //
  3. /*****************************************************************************
  4.  * Display A Square
  5.  * __________________________________________________________________________
  6.  * This program creates a square by asking a user for an integer less than 15
  7.  * ___________________________________________________________________________
  8.  * INPUT:
  9.  * side :Sides
  10.  * OUTPUT:
  11.  * N/A :No output Varaiables
  12.  ****************************************************************************/
  13. #include <iostream>
  14. using namespace std;
  15.  
  16. int main() {
  17. //INPUTS
  18. int side = 0; //Only Input for Dimensions
  19.  
  20. //Input Prompt
  21. while (side < 1 || side > 15)
  22. {
  23. cout << "Enter The Side Length of The Square (1-15)" << endl;
  24. cin >> side;
  25. if (side < 1 || side > 15)
  26. {
  27. cout << "Invalid Side Length: Integer Between 1-15" << endl;
  28. }
  29. }
  30. cout << endl;
  31. cout << "You Entered: " << side << endl;
  32.  
  33. cout << endl;
  34.  
  35. for (int count = 0; count < side; count++)
  36. {
  37. for (int count = 0; count < side; count++)
  38. {
  39. cout << "X";
  40. }
  41. cout << endl;
  42. }
  43.  
  44. cout << endl;
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5316KB
stdin
8
stdout
Enter The Side Length of The Square (1-15)

You Entered: 8

XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX