title: Return of my program isn't functioning as intended
body: <p>I'm having a really weird problem I can't seem to nail down. I need to provide a way to step back from one menu to the previous menu, my program does this, however once I have entered the secondary menu which I have programmed as a function when I step back to the previous menu in the main function it requires that you select the quit option in the first menu twice before the program actually returns 0 and prompts to close the console. I understand that my code is messy right now, because I am in the middle of putting things together and I am still learning. It does not have any critical errors (compiles and runs in my intended output excepting the issue stated), It does contain a few warnings (most of which will be corrected when I finish it) I have not tried using global variables because everyone seems to hate them, but I am wondering if global variables are required for concurrency between methods when not using pointers (something I have not learned how to use yet). I am only asking for an explaination of what I have done wrong and what I can do to fix it. </p>
  
  <p>My code for the main function.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  
  
  using namespace std;
  int countBySheet();
  int main()
  {
  
      int choice;
  
      cout &lt;&lt; "Express estimator" &lt;&lt; endl;
      cout &lt;&lt; " " &lt;&lt; endl;
      cout &lt;&lt; " " &lt;&lt; endl;
      cout &lt;&lt; " " &lt;&lt; endl;
      cout &lt;&lt; "1. Count by Sheet (eg. Lighting, Service, Site Lighting, Power)" &lt;&lt; endl;
      cout &lt;&lt; "2. Count by Category (eg. Building, HVAC, Large Circuits, Service, Site Lighting)" &lt;&lt; endl;
      cout &lt;&lt; "3. Quit Program" &lt;&lt; endl;
      cin &gt;&gt; choice;
          switch(choice) {
  
              case 1: cout &lt;&lt; "Count by Sheet" &lt;&lt; endl;
              cout &lt;&lt; " " &lt;&lt; endl;
              cout &lt;&lt; choice &lt;&lt; " is the value of the CHOICE variable" &lt;&lt; endl;
              cout &lt;&lt; " " &lt;&lt; endl;
              countBySheet();
              break;
              case 2: cout &lt;&lt; "Count by Category" &lt;&lt; endl;
              cout &lt;&lt; " " &lt;&lt; endl;
              cout &lt;&lt; choice &lt;&lt; " is the value of the CHOICE variable" &lt;&lt; endl;
              cout &lt;&lt; " " &lt;&lt; endl;
              //create count by category function
              break;
              case 3: cout &lt;&lt; "Quit program" &lt;&lt; endl;
              return 0;
  
              }
              if(choice =1){ main();}
              else if (choice =2) {main();}
                  else if (choice=3) {return 3;}
  // I originally had one else if statement and allowed the console to terminate from the return statement included in case 3, this produced the explained effect after I chose case 1 or case 2 first, I then added the second else if statement with a return 0 and the explained effect continued, I changed the return statement to 3 to see if that would make a difference, it does not.
              }````
  
  My code for the Secondary function.
  
  </code></pre>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  
  
  using namespace std;
  int main();
  int countBySheet()
  {
  
  int choice;
  
  cout &lt;&lt; "By Sheet" &lt;&lt; endl;
  cout &lt;&lt; " " &lt;&lt; endl;
  cout &lt;&lt; " " &lt;&lt; endl;
  cout &lt;&lt; " " &lt;&lt; endl;
  cout &lt;&lt; "1. Lighting Plan" &lt;&lt; endl;
  cout &lt;&lt; "2. Power Plan" &lt;&lt; endl;
  cout &lt;&lt; "3. Service plan" &lt;&lt; endl;
  cout &lt;&lt; "4. Site plan" &lt;&lt; endl;
  cout &lt;&lt; "5. Back" &lt;&lt; endl;
  cin &gt;&gt; choice;
      switch(choice) {
  
          case 1: cout &lt;&lt; "Lighting Plan" &lt;&lt; endl;
          //create count by sheet function
          break;
          case 2: cout &lt;&lt; "Power Plan" &lt;&lt; endl;
          //create count by category function
          break;
          case 3: cout &lt;&lt; "Service Plan" &lt;&lt; endl;
          break;
          case 4: cout &lt;&lt; "Site Plan" &lt;&lt; endl;
          break;
          case 5: cout &lt;&lt; "Back" &lt;&lt; endl;
  
          return main();
  
          }
          if(choice =1){ countBySheet();}
          else if (choice =2) {countBySheet();}
  
          }
  </code></pre>
  
  <pre><code>
  </code></pre>