title: How can I make this function output max array value?
body: <p>I'm new to C++ and trying to make this piece of code work properly. It's a basic algorithm for 
  prime numbers. I make an array the size of which is defined by the user input. Then I need to print 
  only the max prime number from this array. How can I do that here?</p>
  
  <pre><code>unsigned long long nPrime(unsigned n) {
      long long *a = new long long[n + 1];
      long long maxNum = a[n];
  
      for (int i = 0; i &lt; n + 1; i++) {
              a[i] = i;
      }
      for (int j = 2; j &lt; n + 1; j++) {
          if (a[j] != 0) {
              for (int k = j * j; k &lt; n + 1; k += j) {
                  a[k] = 0;
              }
              cout &lt;&lt; a[j] &lt;&lt; endl;
          }
      }
      return 0;
  }
  </code></pre>