fork download
  1. //Cecilia Rangel CSC5 Chapter 5, P.298, #22
  2. //
  3. /**************************************************************
  4.  *
  5.  * SQUARE DISPLAY
  6.  * ____________________________________________________________
  7.  * This program will ask for a user input between the numbers 0-15 that will
  8.  * be the length and width of a box.
  9.  *_____________________________________________________________
  10.  * INPUT
  11.  * user input : a number between 0 - 15
  12.  *
  13.  * OUTPUT
  14.  * Box : a square made of "X" s by the height and
  15.  * length of the input
  16.  *
  17.  **************************************************************/
  18. #include <iostream>
  19. #include <iomanip>
  20. using namespace std;
  21.  
  22. int main() {
  23. //Program Variables
  24.  
  25. int row;
  26. int column;
  27. int x;
  28.  
  29. //Setting up input
  30.  
  31. cout << "Enter a positive number no larger than 15: \n";
  32. cin >> row;
  33.  
  34. //Intialization of Loop
  35. if (row > 0 && row < 15) {
  36. for (column = 0; column < row; column++) {
  37. for (x = 0; x < row; x++) {
  38. cout << "X";
  39. }
  40. cout << endl;
  41. }
  42. }
  43. else {
  44. cout << "Enter a number within range.";
  45. }
  46. return 0;
  47. }
Success #stdin #stdout 0.01s 5316KB
stdin
8
stdout
Enter a positive number no larger than 15: 
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX