title: Unusual Behavior observed while calling main() in any other function in c++
body: <p>I made a simple program to test whether I am able to call main in any other function like we call different functions in other function.</p>
  
  <p>Therefore, I made a program to generate the maximum number by getting input of 3 numbers from the user. For this I made the function containing if else. Surprisingly (especially for me) it worked. I got that I am keep inputting the numbers then I made another variable to control the inputs. I made it to input 3 times. I got answer from bottom to end and 3 answers are generated.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main();
  void max(int a, int b, int c,int p);
  int p = 0;
  int main()
  {
      p++;
      int a, b, c;
      cout &lt;&lt; "\n\n";
      cout &lt;&lt; "Enter 1st number :\t";
      cin &gt;&gt; a;
      cout &lt;&lt; "Enter 2nd number :\t";
      cin &gt;&gt; b;
      cout &lt;&lt; "Enter 3rd number :\t";
      cin &gt;&gt; c;
      max(a, b, c, p);
      cout &lt;&lt; "\n\n\n";
      system("pause");
      return 0;
  }
  void max(int a, int b, int c,int p)
  {
      if (p &lt; 3) 
      {
          main();
      }
      if (a &gt; b&amp;&amp;a &gt; c)
      {
          cout &lt;&lt; a &lt;&lt; " is maximum";
      }
      else if (b &gt; a&amp;&amp;b &gt; c)
      {
          cout &lt;&lt; b &lt;&lt; " is maximum";
      }
      else
      {
          cout &lt;&lt; c &lt;&lt; " is maximum";
      }
  }
  </code></pre>
  
  <p>The output was as follows: -</p>
  
  <pre><code>
  
  Enter 1st number :      12                                                                                              
  Enter 2nd number :      14                                                                                              
  Enter 3rd number :      15
  
  
  Enter 1st number :      45                                                                                              
  Enter 2nd number :      69                                                                                              
  Enter 3rd number :      88  
  
  
  Enter 1st number :      14                                                                                      
  Enter 2nd number :      20                                                                                              
  Enter 3rd number :      11                                                                                             
  20 is maximum             
  
  
                                                                                                                                                                                                                                                                                                                                                Press any key to continue . . .                                                                                         
  88 is maximum                                                                                                                                                                                                                                                                                                                                                           
  
  
  
  Press any key to continue . . .                                                                                         
  15 is maximum                                                                                                                                                                                                                                                                                                                                                           
  
  
  
  Press any key to continue . . .  
  </code></pre>
  
  <p>I don't get the logic behind it. I used Visual Studio 2017 for this.</p>