Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- #include<stdio.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;
- cin>>temp->eno;
- 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;
- cout<<temp->ename;
- temp=temp->link;
- }
- }
- void main()
- {
- clrscr();
- char ch;
- cout<<"enter choice: 1. insert 2.display 3.exit";
- cin>>ch;
- switch (ch)
- {
- case 1:
- { insert();
- break;
- }
- case 2:
- { display();
- break;
- }
- case 3:
- { break;
- }
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement