title: C | Print Boxes inside of Boxes with only for/while loops and if/else statements
body: <p>My code has an error that prints the boxes on separate lines instead of inside of each other. I'm assuming that the problem lies with my initial for-loop; I am unsure how to adjust the algorithm.
  Any help would be greatly appreciated!</p>
  
  <p>Here is what I need:</p>
  
  <p><a href="https://i.stack.imgur.com/wiFNA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wiFNA.jpg" alt="enter image description here"></a></p>
  
  <p>This is the code I currently have and its output:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
  
      int boxes;
  
      printf("How many boxes: ");
      scanf("%d", &amp;boxes);
  
  
      int boxSide = boxes *3 + (boxes - 1);
      int i;
      int j;
  
      for (i = 0, j = 0; i &lt; boxes; i++, j += 2) { 
  
          int row = 1;   
  
              while (row &lt;= boxSide) {
  
                  int column = 1;
  
                  while (column &lt;= boxSide) {
  
                      if ( (row == (j+1) &amp;&amp; column &gt;= (j+1) &amp;&amp; column &lt;= boxSide - (j+1)) ||
                           (row == boxSide - j &amp;&amp; column &gt;= (j+1) &amp;&amp; column &lt;= boxSide - (j+1)) ||
                           (column == (j+1) &amp;&amp; row &gt;= (j+1) &amp;&amp; row &lt;= boxSide - (j+1)) ||
                           (column == boxSide - j &amp;&amp; row &gt;= (j+1) &amp;&amp; row &lt;= boxSide - j) ) {
  
                      printf("#");
  
                      }
  
                      else {
                          printf(" ");
                      }
  
                  column++;
  
                  }
  
                  row++;
                  printf("\n");
  
              }
  
      }
      return 0;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/GiqtN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GiqtN.jpg" alt="enter image description here"></a></p>