Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Create a SLL for Employee Record ,id

name ,designation ,salary and mob no


1.Create a SLL for N emp
2.Display the status of SLL and count the
nodes
3.Insertion operations -Front,End,at any
location
4.Deletion operation-

Data -> next

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++;
}

Cout<<”\n The number node :”<<count;


}

You might also like