title: Simple menu in c
body: <p>I am a new computer science student and I am currently working on a university project on super shop management system. </p>
  
  <p>For that, I want a menu system. I tried using switch case.<br>
  It works but, for example, when I press <code>1</code> program goes to another function defined by me.   </p>
  
  <p>But main menu function still appears on the top.<br>
  I want a menu where i will press a number and program will proceed to a certain function clearing the previous commands I used.   </p>
  
  <p>Any help would be appreciated. Thank you.</p>
  
  <p>(I tried using switch case. And I am newbie and don't know anything about file handling and that kind of stuff)</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  #include&lt;stdlib.h&gt;
  
  
  //User defined function declaration
  
  int main_menu();
  int products();
  double payment();
  int customer();
  
  //User defined sub menus
  
  
  
  //under products
  
  int home_products();
  int electronics();
  
  int add_products();
  int remove_products();
  int products_quantity();
  
  //Under payment
  
  double billing();
  
  //under customer menu()
  
  int customer_inf();
  int edit_customer();
  
  
  
  
  int main ()
  {
  int input;
  
  printf("                              Hello ADMIN\n                          SHIRONAMHIN Super Shop\n================================================================================");
  printf("                              -Products\n                              -Payment/Billing\n                              -Customer information\n");
  printf("\n");
  printf(" Press One for Products \n Press two for Billing \n Press Three for Customer information \n Press 0 to terminate program");
  scanf("\n%d", &amp;input);
  if(input==0)
  {
      return 0;  //Program will be terminated if 0 is pressed
  }
  switch(input)
  {
  case 1:
      if(input==1)
      {
          products();
      }
      break;
  case 2:
      if(input==2)
      {
          payment();
      }
      break;
  case 3:
      if(input==3)
      {
          customer();
      }
      break;
  
  default:
      printf("Enter a valid number");
      break;
  }
   }
  
  
    int products()
  
    {
      int input;
  printf("\n                              -Home products\n                              -Electronics\n\n Press any key rather than 1 and 2 two return to main menu");
  
  scanf("%d", &amp;input);
  
  switch (input)
  {
  case 1:
      if(input == 1)
          home_products();
      break;
  
  case 2:
      if(input == 2)
          electronics();
      break;
  
  default:
      main();
      break;
  }
  
     }
  
     int home_products()
       {
        int input;
           printf("Code yet to be written\n\n return to main menu by pressing 1 on the keyboard");
      scanf("%d", &amp;input);
        if(input == 1)
         {
           return main();
       }
  
  
        }
  
     int electronics()
         {
        printf("Code yet to be written");
          }
  
        double payment()
        {
  
          return main();
  
        }
  
        int customer()
            {
       printf("Code yet to be written");
  
        return main();
            }
  </code></pre>