title: Comparing the elements of two integer arrays in c++
body: <p>I have two integer arrays </p>
  
  <pre><code>#include&lt;iostream&gt; 
  using namespace std;
  int comparetwoarrays( int array1[], int array2[], int ARRAY_SIZE1, int ARRAY_SIZE2 )
  
  int main ()
  {
      int const ARRAY_SIZE = 500;
      int const ARRAY_SIZE = 10;
      int array1[ARRAY_SIZE];
      int array2[ARRAY_SIZE2];
      comparetwoarrays( array1, array2, ARRAY_SIZE1, ARRAYSIZE2 )
  }
  
  int comparetwoarrays( int array1[], int array2[], int ARRAY_SIZE1, int ARRAY_SIZE2 )
  {
      int holdsAlike[10] = {0};
      for( int g = 0; g &lt; ARRAY_SIZE2; g++ )
      {
          for ( int t = 0; t &lt; ARRAY_SIZE2; t++ )
          {
              if ( array2[g] == array1[t])
              {
                   holdsAlike[g] = array2[g];
                   cout&lt;&lt;holdsAlike[g];
              }
              for( int w = 0; w &lt; ARRAY_SIZE2; w++ )
              {
                   if( holdsAlike[w] != 0 )
                   cout&lt;&lt;holdsAlike[w];
              }
          }
      }
  </code></pre>
  
  <p>I want to compare the elements of both arrays, and print out the value and the index of the element. Not sure how to go about getting this done. Any insight would be appreciated.</p>