Skip to content

Commit 30166e8

Browse files
Merge pull request #1 from gautamdewasi/master
creating documentation
2 parents 8239dd9 + d035107 commit 30166e8

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

LinkedList/Create_list.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,44 @@
1+
//.......................................This program is used to define Link least using structure.........................................................
12
#include<iostream>
23
using namespace std;
4+
5+
//.......................node is user define datatype , which contain two elements in it....................................
6+
// 1) integer data (its own data)
7+
// 2) node type pointer, used to store address of next node
38
struct node{
49
int data;
510
node *next;
611
};
7-
void printList(node *n){
8-
while(n!=NULL){
12+
13+
// printList() function is used to print data stores in all nodes
14+
void printList(node *n)
15+
{
16+
while(n!=NULL){
917
cout<<n->data<<endl;
1018
n=n->next;
1119

1220
}
1321
}
1422

1523
int main(){
24+
25+
// defining three pointers of type node, use to point elements of node
1626
node *head=new node();
1727
node *second=new node();
1828
node *third=new node();
29+
1930
head->data=5;
31+
// next pointer of head node stores addresscof second node
2032
head->next=second;
2133

2234
second->data=9;
35+
// next pointer of second node stores address of third node
2336
second->next=third;
2437

2538
third->data=7;
39+
// next pointer of third node stores NULL value in it, because there is no next node
2640
third->next=NULL;
27-
41+
42+
// calling to print data of all nodes, using only head node
2843
printList(head);
29-
}
44+
}

0 commit comments

Comments
 (0)