title: To Compare two Integer Arrays are equal Or Not
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  bool equal_arr(int* arr, int* arr2, int m, int n)
  {
      if (m != n)
      {
          return false;
      }
      int i = 0, j = 0;
      bool res = false;
      while (i &lt; n)
      {
          if (arr[i] == arr2[j])
          {
              res = true;
              i++;
              j++;
          }
          else
          {
              i++;
              j++;
              res = false;
          }
          return res;
      }
  }
  
  int main(void)
  {
      int arr[5] = { 4, 4, 4, 4, 4 };
      int arr2[5] = { 4, 5, 2, 8, 6 };
      if (equal_arr(arr, arr2, 5, 5))
          cout &lt;&lt; &quot;true&quot; &lt;&lt; endl;
      else
          cout &lt;&lt; &quot;false&quot;;
      return 0;
  }
  </code></pre>
  <p>the above code should print true or false while comparing between two arrays, but it gives a wrong output while at any occurance if both element between the arrays is same it returns true for some logical issues,in my sample testcase you can see it.</p>