- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkedListBasic.cpp
More file actions
Latest commit
30 lines (30 loc) · 497 Bytes
/
Copy pathLinkedListBasic.cpp
File metadata and controls
30 lines (30 loc) · 497 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<iostream>
usingnamespacestd;
structNode{
int data;
Node* next;
};
voidtraverse(Node *n)
{
while(n!=NULL)
{
cout<<n->data<<"";
n=n->next;
}
}
intmain()
{
Node* head=newNode();
Node* first=newNode();
Node* second=newNode();
head->data=5;
head->next=first;
first->data=6;
first->next=second;
second->data=7;
second->next=NULL;
cout<<"Head : "<<head->data<<endl;
cout<<"Traversing Linked List are : ";
traverse(head);
return0;
}