title: How to print 5 values per line in C++ using only loop statement and no if-statements?
body: <p>I want to write a program that prints numbers from 1 to 50 with 6 values per line and have a blank space between the values. I need to use only a for loop statement without using an if statement. </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
      int a;
      int b;
      int c;
      int d;
      int e;
  
      for(int a = 1, int b = 2, int c = 3, int d = 4, int e = 5; a &lt;= 50, b &lt;= 50, c &lt;= 50, d &lt;= 50, e &lt;= 50; a++, b++, c++, d++, e++) {
          cout &lt;&lt; a &lt;&lt; "  "&lt;&lt; b&lt;&lt; "  "&lt;&lt; c &lt;&lt; "  "&lt;&lt; d&lt;&lt; "  "&lt;&lt; e &lt;&lt;"  " &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>This is the program if I used an if-statement, but I am unsure how to compile this without using the if-statement:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
  for(int i = 1; i &lt;= 100; i++){
      cout &lt;&lt; i &lt;&lt; "  ";
          if(i % 5 == 0)
              cout &lt;&lt; endl;
  }
  return 0;
  </code></pre>
  
  <p>}</p>