//Program in cpp to demonstrate linkedlist, linkedlist.cpp
#include<iostream>
using namespace std;
struct node
{
public:
int data;
node * next;
};
class linkedlist
{
private:
node* first;
public:
linkedlist()
{
first=NULL;
}
void getdata(int d);
void display();
};
void linkedlist::getdata(int dd)
{
node* newnode=new node;
newnode->data=dd;
newnode->next=first;
first=newnode;
}
void linkedlist::display()
{
node* current=first;
while(current!=NULL)
{
cout<<current->data<<endl;
current=current->next;
}
}
int main()
{
linkedlist li;
li.getdata(10);
li.getdata(15);
li.getdata(20);
li.getdata(18);
li.getdata(19);
li.display();
return 0;
}
You may also Like:
C++ Program for Circular Queue implementation using linked list
C++ program for Circular Queue implementation using Array
C++ program for reversing single Linked list nodes
C++ Program for sorted single linked list with class
C++ Program for BST-Binary Search Tree
#include<iostream>
using namespace std;
struct node
{
public:
int data;
node * next;
};
class linkedlist
{
private:
node* first;
public:
linkedlist()
{
first=NULL;
}
void getdata(int d);
void display();
};
void linkedlist::getdata(int dd)
{
node* newnode=new node;
newnode->data=dd;
newnode->next=first;
first=newnode;
}
void linkedlist::display()
{
node* current=first;
while(current!=NULL)
{
cout<<current->data<<endl;
current=current->next;
}
}
int main()
{
linkedlist li;
li.getdata(10);
li.getdata(15);
li.getdata(20);
li.getdata(18);
li.getdata(19);
li.display();
return 0;
}
You may also Like:
C++ Program for Circular Queue implementation using linked list
C++ program for Circular Queue implementation using Array
C++ program for reversing single Linked list nodes
C++ Program for sorted single linked list with class
C++ Program for BST-Binary Search Tree
Program in cpp to demonstrate linkedlist, linkedlist.cpp
ReplyDeleteProgram in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
ReplyDeleteProgram in cpp to demonstrate linkedlist, linkedlist.cpp
Program in C++ to demonstrate linked list, linkedlist.cpp
Program in cpp to demonstrate linkedlist, linkedlist.cpp
Other variations of Linked List programs:
ReplyDeletehttp://www.howtocpp.com/p/blog-page.html