 <p>When you invoke the <code>printloop</code> function with <code>5</code> the for loop essentially becomes</p> <pre><code>for (x = 5; x &lt; 5; x++) { //... } </code></pre> <p>And <code>x &lt; 5</code> will never be true.</p> <hr> <p>I guess what you meant was something like </p> <pre><code>for (x = 0; x &lt; valx; x++) { //... } </code></pre>