title: Swap elements in array to reverse an array
body: <p>I got an assignment to reverse an dynamic array in C++. So far, from my logic, I thinking of loop thru the array to reverse it. And here comes my code :</p>
  
  <pre><code>int main ()
  {
      const int size = 10;
      int num_array[size];
  
      srand (time(NULL));
  
      for (int count = 0; count&lt; sizeof(num_array)/sizeof(num_array[0]) ; count++){
          /* generate secret number between 1 and 100: */
          num_array[count] = rand() % 100 + 1;
          cout &lt;&lt; num_array[count] &lt;&lt; " " ;
      }
  
      reverse(num_array[size],size);
  
      cout &lt;&lt; endl;
  
      system("PAUSE");
      return 0;
  }
  
  void reverse(int num_array[], int size)
  {
      for (int count =0; count&lt; sizeof(num_array)/sizeof(num_array[0]); count++){
          cout &lt;&lt; num_array[sizeof(num_array)/sizeof(num_array[0])-1-count] &lt;&lt; " " ;
      }
  
      return;
  }
  </code></pre>
  
  <p>Somehow I think my logic was there but this code doesn't works, there's some error. However, my teacher told me that this isn't the way what the question wants. And here is the question :</p>
  
  <pre><code>    Write a function reverse that reverses the sequence of elements in an array. For example, if reverse is called with an array containing 1 4 9 16 9 7 4 9 11,
  then the array is changed to 11 9 4 7 9 16 9 4 1.
  </code></pre>
  
  <p>So far, she told us in the reverse method, you need to swap for the array element. So here's my question <strong>how to swap array element so that the array entered would be reversed</strong>?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Updated portion</strong></p>
  
  <pre><code>    int main ()
  {
  const int size = 10;
  int num_array[size];
  
  srand (time(NULL));
  
  for (int count = 0; count&lt; size ; count++){
      /* generate secret number between 1 and 100: */
      num_array[count] = rand() % 100 + 1;
      cout &lt;&lt; num_array[count] &lt;&lt; " " ;
  }
  
  reverse(num_array,size);
  
  cout &lt;&lt; endl;
  
  system("PAUSE");
  return 0;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>void reverse(int num_array[], const int&amp; size)
  {
  for (int count =0; count&lt; size/2; count++){
      int first = num_array[0];
      int last = num_array[count-1];
      int temp = first;
      first = last;
      last = temp;
  }
  </code></pre>
  
  <p>}</p>