title: The result of my code is zero and I don't know why
body: <p>The question is to print out the smallest prime number but bigger than other not prime number. after hours of work, my code print out 0 no matter what I type in. Where have I gone wrong? </p>
  
  <p>(I posted this yesterday but because of my lack of communication ability, no one seem to figure out the problem, I have tried harder, hoping today will be different).</p>
  
  <p>For example: 4 7 8 11 then the result is 11 because 11 is the smallest prime number and bigger then the biggest non-prime number (which is 8). Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;complex&gt;
  using namespace std;
  
  void TypeIn(int a[] ,int &amp;n)
      {
              cout&lt;&lt; "\nType in n: ";
              cin &gt;&gt; n;
              for(int i=0; i&lt;n; i++)
                  {
                  cout &lt;&lt; "a[" &lt;&lt; i &lt;&lt; "]= ";
                  cin &gt;&gt; a[i];
                  }
      }
  int CheckPrimeNum(int Number)
  {
      int Count=0;
      int Divisor =1;
      while (Number &gt;= Divisor)
      {
          if(Number % Divisor == 0)
          {
              Count++;
          }
      Divisor++;
      }
      return Count;
  }
  int BiggestNotPrime(int a[], int n)
  {
      int BiggestNotPrime =0;
      for( int i=0; i&lt;n; i++)
      {
          if( CheckPrimeNum(a[i]) !=2)
          {
          BiggestNotPrime = a[i];
          break;
          }
      }
      if(BiggestNotPrime ==0)
      {
          return 0;
      }
      else
      {
      for( int i=0; i&lt;n; i++)
      {
          if(CheckPrimeNum(a[i])!=2 &amp;&amp; a[i] &gt; BiggestNotPrime)
          BiggestNotPrime =a[i];
      }
      return BiggestNotPrime;
      }
  }
  int main()
  {
      int n;
      int a[100];
      TypeIn(a,n);
      int SmallestPrimeLocation =0;
      for(int i=0; i&lt;n; i++)
      {
          if(CheckPrimeNum(a[i])==2 &amp;&amp; a[i]&gt; BiggestNotPrime(a,n))
              SmallestPrimeLocation =i;
              break;
      }
      if(SmallestPrimeLocation ==0)
      {
          cout &lt;&lt; 0;
      }
      else
      {
          for(int i=SmallestPrimeLocation; i&lt;n; i++)
          {
              if(a[i]&gt;BiggestNotPrime(a,n) &amp;&amp; a[i] &lt; a[SmallestPrimeLocation] &amp;&amp; CheckPrimeNum(a[i])==2)
              {
                  SmallestPrimeLocation=i;
              }
          }
          cout &lt;&lt; a[SmallestPrimeLocation];
      }
      return 0;
  }
  </code></pre>