title: How to infinite loop or loop up to a limit without an if-else
body: <p>I'm wondering if there's a way to write a function that takes one input, a max count for the number of times to loop, that will do an infinite loop if the number is negative, without using an if-else</p>
  
  <p>i.e.</p>
  
  <pre><code>void func(int nAttempts) // if nAttempts &lt;= 0, do an infinite loop
  {
    if ( nAttempts &lt;= 0 )
    { // do an infinite loop
    }
    else
    { // do a loop up to nAttemtps
    }
  }
  </code></pre>
  
  <p>I'd like to know if there's a way to do that without an if-else</p>