singly linked list with three nodes
Sun May 14 2023 19:21:59 GMT+0000 (Coordinated Universal Time)
Saved by
@prachi
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
void print_linked_list(struct node *n)
{
while(n!=NULL)
{
printf("%d ",n -> data);
n = n -> next;
}
}
int main()
{
struct node *first = NULL;
struct node *second = NULL;
struct node *third = NULL;
first = (struct node*)malloc(sizeof(struct node));
second = (struct node*)malloc(sizeof(struct node));
third = (struct node*)malloc(sizeof(struct node));
first->data=1;
first->next=second;
second->data=2;
second->next=third;
third->data=3;
third->next=NULL;
print_linked_list(first);
}
content_copyCOPY
Comments