forked from H4ckOm/Optimizations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraverse.cpp
More file actions
32 lines (32 loc) · 710 Bytes
/
traverse.cpp
File metadata and controls
32 lines (32 loc) · 710 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
31
32
#include<stdio.h>
#include<stdlib.h>
struct node{
int data;
struct node* next;
};
int main(){
struct node* head=NULL;
struct node* first=NULL;
struct node* second=NULL;
struct node* third=NULL;
head=(struct node*)malloc(sizeof(struct node));
first=(struct node*)malloc(sizeof(struct node));
second=(struct node*)malloc(sizeof(struct node));
third=(struct node*)malloc(sizeof(struct node));
head->data=3;
head->next=first;
first->data=7;
first->next=second;
second->data=27;
second->next=third;
third->data=25;
third->next=NULL;
struct node*temp;
temp=(struct node*)malloc(sizeof(struct node));
temp=head;
while(temp!=NULL){
printf("%d\n",temp->data);
temp=temp->next;
}
return 0;
}