Advertisement
abhask

modified queue program

Oct 31st, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1.     #include<iostream.h>
  2.     #include<conio.h>
  3.     #include<stdio.h>
  4.     #include<process.h>
  5.     struct emp
  6.     { int eno;
  7.       char ename[15];
  8.        emp *link;
  9.  
  10.     };
  11.     emp *front=NULL;
  12.     emp *rear=NULL;
  13.     emp *temp=NULL;
  14.     void insert()
  15.     {
  16.       emp *temp=new emp;
  17.       cout<<"enter element\n";
  18.       cin>>temp->eno;
  19.       cout<<"enter employee name\n";
  20.       gets(temp->ename);
  21.       temp->link=NULL;
  22.       if (front==NULL)
  23.       {
  24.      front=temp;
  25.      rear=temp;
  26.       }
  27.       else
  28.        {    rear->link=temp;
  29.         rear=temp;
  30.        };
  31.     }
  32.     void display()
  33.     { temp=front;
  34.       while(temp!=NULL)
  35.     {
  36.       cout<<temp->eno<<"\n";
  37.       cout<<temp->ename<<"\n";
  38.       temp=temp->link;
  39.     }
  40.      }
  41.     void main()
  42.     {
  43.     clrscr();
  44.     int ch;
  45.     while(1)
  46.     {
  47.     cout<<"enter choice:\n 1.insert\n 2.display\n 3.exit";
  48.     cin>>ch;
  49.     switch (ch)
  50.     {
  51.      case 1:
  52.     insert();
  53.       break;
  54.  
  55.      case 2:
  56.     display();
  57.      break;
  58.  
  59.      case 3:
  60.      exit(0);
  61.      }
  62.     }
  63.     getch();
  64.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement