PROGRAM-10


// Program of Menu driven
#include
#include
void main()
{ clrscr();
 int num,i,choice,f=1;
 printf("menu driven\n");
 printf("1 select as even/odd\n");
 printf("2 select finding the factorial\n");
 printf("3 select positive or negative\n");
printf("4 exit\n");
printf(" enter the choice 1,2,3,4\n");
scanf("%d", &choice);
switch(choice)
                {
case 1:
                printf("enter the number");
                scanf("%d", &num);
                if(num%2==0)
                printf("the number is even");
                else
                printf("the number is odd");
                break;
case 2:
                printf("the value should greater than zero");
                scanf("%d", &num);
                i=num;
                for(i=num; i>=1; i--)
                {
                 f=f*i;
                }
                printf("the factorial of the number is %d", f);
                break;
case 3:
                printf("enter the number");
                scanf("%d", &num);
                if(num>0)
                printf("the number is positive");
                else
                printf("the number is negayive");
                break;
case 4:
       printf("exit");
                break;
default:
  printf("read carefully, then enter the number");
  break;
}
 getch();
}

Algorithm

·                     Start
·                     Declare num, i, choice, f=1 as integer
·                      Write("menu driven")
·                      Write("1 select as even/odd")
·                      Write("2 select finding the factorial")
·                      Write("3 select positive or negative")
·                     Write("4 exit")
·                     Write(" the choice 1,2,3,4")
·                     Read(“the choice”)
·                     switch(choice)
·                     case start
·                     case1:
·                                     Write("the number")
·                                     Read(“the number”)
·                                     if(num%2==0)
·                                     Read("the number is even")
·                                     else
·                                     Read("the number is odd")
·                                     break
·                     case 2:
·                                     Write("the value should greater than zero")
·                                     Read(“the number)
·                                     i=num
·                                     for(i=num; i>=1; i--)
·                                      f=f*i
·                                     Read("the factorial of the number is " )
·                                     break
·                     case 3:
·                     Write("the number")
·                     Read(“the number)
·                                     if(num>0)
·                                     Read("the number is positive")
·                                     else
·                                     Read("the number is negative")
·                                     break
·                     case 4:
·                            Read("exit")
·                                     break;
·                     default:
·                       Read("read carefully, then enter the
number")
·                       break;
·                      stop




#vpsinghrajput

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

1 comments: