title: Same Code Returning Different Values in gcc compiler & Turbo C
body: <p>While Executing the below code for an array size of 2 with 2 identical elements say 11,11 both the compilers return the correct upper &amp; lower bound of the array. But when executing the same for (1,1), gcc returns -1(number not in array) for upper bound whereas turbo C returns 1 for the same.</p>
  
  <pre><code>int binarylower(int a[],int m,int l,int u,int uorl)
  {
      int mid;
  
      if(l&lt;=u)
      {   //finds the mid position
          mid=(l+u)/2;
          if (uorl == 1)
          {
              if(m==a[mid])
              {
                  if ((m != a[mid-1])|| (mid == 0 &amp;&amp; m==a[mid]))
                  {
                      return mid;
                  }
                  else
                  {
                      return binarylower(a,m,l,mid-1,1);
                  }
              }
              else if(m&lt;a[mid])
              {
                  return binarylower(a,m,l,mid-1,1);
              }
              else 
              {
                  return binarylower(a,m,mid+1,u,1);
              }
          }
          else if(uorl == 2)
          {
              if(m==a[mid])
              {            
                  if ((m != a[mid+1]))
                  {
                      return mid;
                      }
                      else
                      {
                      return binarylower(a,m,mid+1,u,2);
                      }
              }           
              else if(m &lt; a[mid])
              {           
                  return binarylower(a,m,l,mid-1,2);
              }           
              else
              {
                  return binarylower(a,m,mid+1,u,2);
              }
          }
      }
      else
      {
          return -1;
      }
  }
  </code></pre>