Skip to content

creating documentation #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Jan 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions LinkedList/Create_list.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
//.......................................This program is used to define Link least using structure.........................................................
#include<iostream>
using namespace std;

//.......................node is user define datatype , which contain two elements in it....................................
// 1) integer data (its own data)
// 2) node type pointer, used to store address of next node
struct node{
int data;
node *next;
};
void printList(node *n){
while(n!=NULL){

// printList() function is used to print data stores in all nodes
void printList(node *n)
{
while(n!=NULL){
cout<<n->data<<endl;
n=n->next;

}
}

int main(){

// defining three pointers of type node, use to point elements of node
node *head=new node();
node *second=new node();
node *third=new node();

head->data=5;
// next pointer of head node stores addresscof second node
head->next=second;

second->data=9;
// next pointer of second node stores address of third node
second->next=third;

third->data=7;
// next pointer of third node stores NULL value in it, because there is no next node
third->next=NULL;


// calling to print data of all nodes, using only head node
printList(head);
}
}