LINK LIST PROGRAM
Creating Node
#include
using namespace std;
class node{
private :
int data,size;
node *next,*current,*head,*temp;
public:
node()
{
head=NULL;
temp=NULL;
current=NULL;
next=NULL;
size=0;
}
void insert()
{
int d;
cout<<"enter the value for the node :"
cin>>d;
temp=new node;
temp->data=d;
temp->next=NULL;
size++;
if(head==NULL)
{
head=temp;
current=temp;
}
else
{
current->next=temp;
current=current->next;
}
}
void display()
{
temp=head;
while(temp!=NULL)
{
cout<data<next;
}
}
};
int main()
{
node n;
n.insert();n.insert();n.insert();n.insert();
n.display();
}
for video click to watch video
#include
Comments
Post a Comment