Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- #include<stdio.h>
- #include<process.h>
- struct emp
- { int eno;
- char ename[15];
- emp *link;
- };
- emp *front=NULL;
- emp *rear=NULL;
- emp *temp=NULL;
- void insert()
- {
- emp *temp=new emp;
- cout<<"enter element\n";
- cin>>temp->eno;
- cout<<"enter employee name\n";
- gets(temp->ename);
- temp->link=NULL;
- if (front==NULL)
- {
- front=temp;
- rear=temp;
- }
- else
- { rear->link=temp;
- rear=temp;
- };
- }
- void display()
- { temp=front;
- while(temp!=NULL)
- {
- cout<<temp->eno<<"\n";
- cout<<temp->ename<<"\n";
- temp=temp->link;
- }
- }
- void main()
- {
- clrscr();
- int ch;
- while(1)
- {
- cout<<"enter choice:\n 1.insert\n 2.display\n 3.exit";
- cin>>ch;
- switch (ch)
- {
- case 1:
- insert();
- break;
- case 2:
- display();
- break;
- case 3:
- exit(0);
- }
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement