title: menu based program using do while
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  
  void main()
  {
      int choice,cala,calb,add,product,subtract,mod,bininput, c, k,perfectinput, perfecttotal, perfecti,primei, primeinput, flagprime,factinput,factorial,facti;
      float divide;
      do
      {
      printf("********** Main Menu **********\n(1).Calculator\n(2).Decimal to Binary convertor\n(3).Perfect number finder\n(4).Prime number or composite number\n(5).Factorial Calculator\n(6).To exit\n");
      scanf("%d",choice);
  
      switch (choice)
      {
      case 1:
                      clrscr();
                      printf("********** Calculator **********\n\nEnter numbers:-\n");
                      scanf("%d%d" , &amp;cala,&amp;calb);
  
                      add = cala + calb;
                      subtract = cala - calb;
                      product = cala * calb;
                      divide = cala / (float)calb;
                      mod = cala % calb;
  
                      printf("Sum = %d\n",add);
                      printf("Sub = %d\n",subtract);
                      printf("product = %d\n",product);
                      printf("divide = %2f\n",divide);
                      printf("mod = %d\n",mod);
                      printf("(0). Return to main menu");
                      printf("\n");
                  break;
  
              case 2:
                  clrscr();
  
                  printf("********** Decimal to Binary convertor **********\n\nEnter an integer in decimal number system:-");
              scanf("%d", &amp;bininput);
  
              printf("%d in binary number system is:\n", bininput);
              printf("\n");
  
              for (c = 10; c &gt;= 0; c--)
              {
                  k = bininput &gt;&gt; c;
  
                  if (k &amp; 1)
                      printf("1");
                  else
                      printf("0");
              }
              printf("\n(0). Return to main menu\n");
              printf("\n");
              printf("\n");
              break;
  
          case 3:
              clrscr();
  
              printf("********** Perfect number finder **********\n");
              printf("Enter a number:- ");
              scanf("%d" ,&amp;perfectinput);
              perfecttotal=0;
              perfecti=1;
              for(perfecti=1;perfecti &lt; perfectinput;perfecti++)
              {
                  if(perfectinput%perfecti == 0)
                  perfecttotal=perfecttotal+perfecti;
              }
              if(perfecttotal==perfectinput)
                  printf("%d is a perfect number\n\n\a\a",perfectinput);
              else
                  printf("%d is not a perfect number\n\n\a",perfectinput);
              printf("(0). Return to main menu\n");
              break;
  
          case 4:
              clrscr();
  
  
              printf("********** Prime number or composite number **********\n");
              printf("Enter a number:- ");
              scanf("%d" ,&amp;primeinput);
              flagprime=0;
              primei=2;
              while(primei &lt;= primeinput/2)
              {
                  if (primeinput%primei == 0)
                  {
                      flagprime=1;
                      break;
                  }
                  primei++;
              }
              if(flagprime==0)
                  printf("%d is a prime number\n\n",primeinput);
              else
                  printf("%d is a composite number\n\n",primeinput);
              printf("(0). Return to main menu\n");
              break;
  
          case 5:
              clrscr();
  
              printf("********** Factorial Calculator **********\n");
              printf("Enter a number:- ");
              scanf("%d" ,&amp;factinput);
              factorial=1;
              for(facti=factinput;facti&gt;0;facti--)
              {
                  factorial=factorial*facti;
              }
              printf("Factorial of %d = %d\n\n",factinput,factorial);
              printf("(0). Return to main menu\n");
              break;
  
          case '6':
                  clrscr();
                  printf("Program terminated.\nPress any key to exit");
                  break;
          default: printf("wrong input");
          }
      }while(choice != 6);
      printf("bye");
      getch();
  }
  </code></pre>