Posts

Showing posts from June, 2021

c++ program to make a linkedlist having n elements

 C++ program to make a linkedlist having n elements #include<iostream> using namespace std; class node{     public:         int data;         node* next;         node(int val){             data=val;             next=NULL;         } }; void tail(node* &head,int val){     node* n=new node(val);     if(head==NULL){         head=n;         return;     }     node* temp=head;     while(temp->next!=NULL){         temp=temp->next;     }     temp->next=n; } void display(node* head){     node* temp=head;     while(temp->next!=NULL){         cout<<temp->data<<" ";         temp=temp->next;     }     c...