title: C/C++ Puzzle: To print values from 1..15 15..1 with a single for loop
body: <p>It was given by my colleague, to print values <code>1 2 3 4 .... 15 15 ..... 4 3 2 1</code> with only <em>one for loop</em>, <em>no functions</em>, <em>no goto statements</em> and <em>without the use of any conditional statements or ternary operators</em>. </p>
  
  <p>So I employed typecasting to solve it, but it is not an exact solution since 15 is not printed twice.</p>
  
  <pre><code>int main()
  {
      int i, j;
      for(i = 1, j = 0;j &lt; 29;j++, i += int(j/15)*-2 + 1)
          cout&lt;&lt;i&lt;&lt;endl;
  }
  </code></pre>
  
  <p><strong>Output</strong>: <code>1 2 3 4 ... 15 14 13 .... 2 1</code></p>
  
  <p>Any alternative solutions?</p>