/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include<iostream>
using namespace std;
class node
{
public:
int Emp_No;
node *next;
node()
{
next=NULL;
}
};
class Link_List
{
public:
node *head;
Link_List()
{
head=NULL;
}
void create();
void display();
};
void Link_List::create()
{
node *temp,*p;
int again;
do
{
temp=new node();
cout<<"Enter Employee No.: ";
cin>>temp->Emp_No;
if (head==NULL)
{
head=temp;
}
else
{
p=head;
while (p->next!=NULL)
{
p=p ->next;
}
p ->next=temp;
}
cout<<"Enter 1 to add more: ";
cin>>again;
} while (again==1);
}
void Link_List::display()
{
node *p1;
if (head==NULL)
{
cout<<"The linked list is empty"<<endl;
}
else
{
p1=head;
while (p1!=NULL)
{
cout<<"Employee No:"<<p1 ->Emp_No<<endl;
p1=p1->next;
}
}
}
int main()
{
Link_List emp1;
emp1.create();
emp1.display();
return 0;
}