Advertisement
abhask

queue- testing

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