title: What is wrong with the logic in my program?
body: <p>I've been tasked to create a function that identifies the number of occurrences in an array, however i am not getting the correct result. This is the function i wrote, i left out the rest of the program as that works.</p>
  
  <pre><code>int countOccurences(int b[], int size, int x)
  {
      int occ = x;
      for(int i = 0; i &lt; size; i++)
      {
              if(b[i] == occ)
              occ++;
  
      }
      cout &lt;&lt; occ &lt;&lt; endl;
  
      return occ;
  }
  </code></pre>