1.write a program store the student name or roll using structure.

 MENU

  1. insert.                                                  
  2.show.       
  3.exit.
input your choice. 

#include<stdio.h>
#include<conio.h>
#include<process.h>

int menu()
{
 int choice;
 clrscr();
 printf("###MENU###");
 printf("\n 1. insert:");
 printf("\n 2. show:");
 printf("\n 3. exit.");
 printf("\n input the your choice:");
 scanf("%d",&choice);
 return choice;
 }
 struct student
 {
  int roll;
  char name[30];
  }s;
  ////////////////////////////////////////////////////////////
  void main()
  {
  char name[40];
  int roll;
   while(1)
   {
    switch(menu())
    {
     case 1:
   printf("input the roll:");
   scanf("%d",&s.roll);
   printf("name:");
   scanf("%s",s.name);
   gets(name);
   break;
    case 2:
  printf("roll: %d",s.roll);
  printf("\n name:%s",s.name);
  getch();
  break;
   case 3:
              exit(1);
  default:
               printf("invalid choice");
  getch();
  }
                 }
                }

 2.write a program and find the

                          MENU        

    1.area of rectangle.                2.perimeter of rectangle.          3.area of square.    input your choice


#include<stdio.h>
#include<conio.h>
#include<process.h>
int areaofrectangle(int l,int b)
{
     return(l*b);
     }
int perimeterofrectangle(int l,int b)
{
   return(2*(l+b));
   }
int areaofsquare(int side)
{
 return(side*side);
 }
int menu()
{
 int choice;
 clrscr();
 printf("###MENU###");
 printf("\n 1. area of rectangle:");
 printf("\n 2. perimeter of rectangle:");
 printf("\n 3. area of square:");
 printf("\n 4. exit.");
 printf("\n input the your choice:");
 scanf("%d",&choice);
 return choice;
 }
  ////////////////////////////////////////////////////////////
  void main()
  {
    int a,b,c;
   while(1)
   {
    switch(menu())
    {
     case 1:
   printf("input the l and b:");
  scanf("%d%d",&a,&b);
c=areaofrectangle(a,b);
printf("area of rectangle=%d",c);
   getch();
break;

    case 2:
   printf("input the l and b:");
scanf("%d%d",&a,&b);
 c=perimeterofrectangle(a,b);
 printf("perimeter of rectangle=%d",c);
 getch();
  break;

    case 3:
   printf("input the side:");
 scanf("%d",&a);
 b=areaofsquare(a);
 printf("area of square=%d",b);
 getch();
 break;

   case 4:
                exit(1);

  default:

              printf("invalid choice");

  getch();

  }

  }

  }

Comments

Popular Posts