title: Reducing If statements in C
body: <p>I was trying to count how many out of my four variables were greater than 0, so I wrote these if statements to achieve my purpose. All numbers will be positive or 0:</p>
  
  <pre><code>            if(a1&gt;0){counter++;}
              if(a2&gt;0){counter++;}
              if(a3&gt;0){counter++;}
              if(a4&gt;0){counter++;}
  
              printf("%d", counter);
  </code></pre>
  
  <p>It's quite obvious that I would run into some trouble if the number of variables were to increase. Is there a more efficient way of writing this?</p>
  
  <p>Thanks for taking the time to help me.</p>