title: Why std::binary_search on an array give different results in cmd and linux terminal?
body: <p>I was trying to solve a <a href="https://codeforces.com/contest/270/problem/A" rel="nofollow noreferrer">codeforces problem</a>, which required me to find the interior angles of polygons using the formula:</p>
  <blockquote>
  <p>((n-2)*180)/n</p>
  </blockquote>
  <p>; where 'n' is number of polygon sides. I took an array of size: 5 to store the angles of triangle(n=3) and square(n=4). The following code was written to search for an angle(60 degrees) on the array:</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;algorithm&gt;
  
  using namespace std;
  
  int main(){
      int arr [5];
      
      for(int n=3; n&lt;5; n++){
              arr[n] = ((n-2)*180)/n;
              cout &lt;&lt; &quot;arr[&quot;&lt;&lt;n&lt;&lt;&quot;] = &quot;&lt;&lt; arr[n];
              cout&lt;&lt;endl;
      }
  
      if(binary_search(arr, arr+5,60)){
                 cout &lt;&lt; &quot;YES&quot;&lt;&lt;&quot;\n&quot;;
      }
      else{
                 cout&lt;&lt; &quot;NO&quot;&lt;&lt;&quot;\n&quot;;
      }   
      return 0;
  }
  </code></pre>
  <p>After compiling and running it on the Command Prompt (cmd), I got the following unexpected result:</p>
  <blockquote>
  <pre><code>arr[3] = 60 
  arr[4] = 90
  NO
  </code></pre>
  </blockquote>
  <p>Later I tried the same code on Windows Subsystem for Linux, and got the following correct output:</p>
  <blockquote>
  <pre><code>arr[3] = 60 
  arr[4] = 90
  YES
  </code></pre>
  </blockquote>
  <p>Why is the std::binary_search() function for 60 in array returning false on cmd? Even thoug its stored at index 3.
  And why is it working on linux terminal?</p>
  <h2>Compiler and C++ used</h2>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>System</th>
  <th style="text-align: center;">g++ --version</th>
  <th style="text-align: center;">C++ standard</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>cmd (Windows)</td>
  <td style="text-align: center;">g++ (MinGW.org GCC-8.2.0-5) 8.2.0</td>
  <td style="text-align: center;">C++14</td>
  </tr>
  <tr>
  <td>linux terminal(wsl)</td>
  <td style="text-align: center;">g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0</td>
  <td style="text-align: center;">C++14</td>
  </tr>
  </tbody>
  </table>
  </div>