title: Convert for to for loop to do while loop
body: <p>I'm trying to convert this <strong>for loop</strong> to a <strong>do while loop</strong> and keep it a <code>7 x 7</code> matrix</p>
  
  <p><em>For loop to print the number <code>7 x 7</code></em>:</p>
  
  <pre><code>for (int height = 0; height &lt; 7; height++){
      cout &lt;&lt; numberMatrix[height][digitOne] &lt;&lt; " ";
      cout &lt;&lt; numberMatrix[height][digitTwo] &lt;&lt; " ";
      cout &lt;&lt; numberMatrix[height][digitThree] &lt;&lt; " ";
      cout &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Right output:</p>
  
  <p><a href="https://i.stack.imgur.com/Hm2er.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hm2er.png" alt="enter image description here"></a></p>
  
  <p>Here is my code after converting but it doesn't come out right.</p>
  
  <p><em>For loop to print the number <code>7 x 7</code></em>:</p>
  
  <pre><code> int height = 0;
      while (height &lt; 7) {
          cout &lt;&lt; numberMatrix[height][digitOne] &lt;&lt; " ";
          cout &lt;&lt; numberMatrix[height][digitTwo] &lt;&lt; " ";
          cout &lt;&lt; numberMatrix[height][digitThree] &lt;&lt; " ";
          height++;
      }
  }
  </code></pre>
  
  <p>Wrong output:</p>
  
  <p><a href="https://i.stack.imgur.com/kl8QY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kl8QY.png" alt="enter image description here"></a></p>