Professional Documents
Culture Documents
Create A SLL For Employee Record
Create A SLL For Employee Record
class emp
{
Public:
Int id,mobno,salary;
Char name[10],deg[10];
emp *next;
Void create();
Void display();
}*start;
110 NULL
Start=NULL=0
Temp
Void emp::create()
{
Emp *temp;
temp=new emp;
cout<<”Enter the empid”;
cin>>temp->id;
temp->next=NULL;
temp->next=start;
start=temp;
0 1 2 3
Temp=Start=100 200 300 400
101 103 104
102
105 NULL
Ptr=1001
Emp *ptr;
Ptr=new emp;
Cout<<”\n Enter the new id”;
Cin>>Ptr->data;
Ptr->next=NULL;
Temp=start;
If(temp==NULL)
{
Temp=ptr;
}
Else
{
While(temp->next!=NULL)
{
Temp=temp->next;
}
Temp->next=ptr;
Void emp::display()
{
Int count=0;
Emp *temp;
temp=start;
if(temp==NULL)
cout<<”\n List is empty”;
else
{
While(temp!=NULL)
{
Cout<<temp->id<<”->”;
temp=temp->next;
count++;
}