Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- typedef struct Node
- {
- int data;
- struct Node *next;
- }
- node;
- int main()
- {
- node *start = (node *)malloc(sizeof(node));
- start->data = 1;
- start->next = NULL;
- node *sf =(node *)malloc(sizeof(node));
- sf->data = 2;
- sf->next = NULL;
- node *tf =(node *)malloc(sizeof(node));
- tf->data = 6;
- tf->next = NULL;
- node *ff =(node *)malloc(sizeof(node));
- ff->data = 8;
- ff->next = NULL;
- node *fif =(node *)malloc(sizeof(node));
- fif->data = 10;
- fif->next = NULL;
- start->next = sf;
- sf->next = tf;
- tf->next = ff;
- ff->next = fif;
- printf("start = %d data1: %d next: %d\n",start ,start->data ,start->next);
- printf("secondFloor = %d data2: %d next: %d\n",sf ,sf->data ,sf->next);
- printf("thirdFloor = %d data3: %d next: %d\n",tf ,tf->data ,tf->next);
- printf("forthFloor = %d data3: %d next: %d\n",ff ,ff->data ,ff->next);
- printf("fifthFloor = %d data3: %d next: %d\n",fif ,fif->data ,fif->next);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement