title: How to remove Warnings From our Code in C++?
body: <p>What does  &quot; control reaches end of non-void function&quot; means??</p>
  <p>How to remove the warnings from out code ?</p>
  <pre><code>#include &lt;bits/stdc++.h&gt;
  using namespace std;
  
  int LinearSearch()
  {
      int ans=-1;
      
      cout &lt;&lt; &quot;Enter the Size of the array:  \n&quot;;
      int n;
      cin &gt;&gt; n;
      cout &lt;&lt; &quot;Enter the array elements: \n&quot;;
      int arr[n];
      for (int i = 0; i &lt; n; i++)
      {
          cin &gt;&gt; arr[i];
      }
      int key;
      cout &lt;&lt; &quot;Enter the key: \n&quot;;
      cin &gt;&gt; key;
      for (int i = 0; i &lt; n; i++)
      {
          if (arr[i] == key)
          {
              cout &lt;&lt; &quot;the &quot; &lt;&lt; key &lt;&lt; &quot; is found at index &quot; &lt;&lt; i &lt;&lt; endl;
          }
          return ans;
      }
  }
  
      int main()
  {
      while (1)
      {
          cout &lt;&lt; &quot;\t Main Menu\n&quot;;
          cout &lt;&lt; &quot;1. For Linear Search\n&quot;;
          cout &lt;&lt; &quot;2. For Binary Search\n&quot;;
          cout &lt;&lt; &quot;3. For First and last Occurence\n&quot;;
  
          int ch;
          cout &lt;&lt; &quot;Enter the choice: \n&quot;;
          cin &gt;&gt; ch;
          switch (ch)
          {
          case 1:
             
            cout&lt;&lt;  LinearSearch();
              break;
          case 2:
  
              break;
          case 3:
  
              break;
  
          default:
              cout &lt;&lt; &quot;Invalid Choice OOps!! &quot;;
              break;
          }
      }
  
      return 0;
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/s0Qxh.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>AS I am trying to run it it is giving me Warning Why??
  Error is: warning: control reaches end of non-void function [-Wreturn-type]
  How to resolve it?</p>