title: Finding the primary numbers in an array of pointer
body: <p>This piece of code which works fine it tells you to enter a number, then it puts
  the number in a for loop and it checks if it's dividable by i, if true it prints not prime if not prints prime. </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
    int x;
    cin &gt;&gt; x;
  
    bool f = true;
    for (int i = 2; i &lt; x; i++) {
      f = false;
      if (i % x == 0)
        f = true;
      if (f)
        cout &lt;&lt; "not primary";
      else
        cout &lt;&lt; "primary";
    }
  }
  </code></pre>
  
  <p>but when i convert it to an array like so:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
    cout &lt;&lt; "the number of array:" &lt;&lt; endl;
    int n;
    cin &gt;&gt; n;
  
    cout &lt;&lt; "enter them = \n";
    int *p = new int[n];
    for (int i = 0; i &lt; n; i++)
      cin &gt;&gt; p[i];
  
    bool f = true;
    for (int i = 0; i &lt; n; i++)
      for (int j = 2; j &lt; p[i]; j++) {
        f = false;
        if (p[i] % j == 0)
          f = true;
        if (f)
          cout &lt;&lt; "This is not a primary number!\n";
        else
          cout &lt;&lt; "this is a primary number!\n";
      }
  
    delete p;
  }
  </code></pre>
  
  <p>it stores just the first number and i get that but how to increment it
  <strong>lets say n =3</strong> 
  so p[3] = {4,6,7};
  my question is how tell the compiler in the j condition
  if (p[0] % j) then(p[1] %j) it seems that it just takes p[0]</p>