0% found this document useful (0 votes)
24 views1 page

Creating Linked List of 2nd Node

The document creates a linked list with two nodes, assigns data values to each node, and links the second node to the first before displaying the linked list data.

Uploaded by

Aashu Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

Creating Linked List of 2nd Node

The document creates a linked list with two nodes, assigns data values to each node, and links the second node to the first before displaying the linked list data.

Uploaded by

Aashu Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//create 2nd node linked list

#include <stdio.h>
#include<stdlib.h>

struct node
{
int data;
struct node* next;
};
void display(struct node*head)
{
struct node*n=malloc(sizeof(struct node));
n=head;

while(n!=NULL)
{
printf("%d",n->data);
n=n->next;
}
}
int main()
{
struct node*head=malloc(sizeof(struct node));
head->data=45;
head->next=NULL;

struct node* ptr=malloc(sizeof(struct node));


ptr->data=46;
ptr->next=NULL;

head->next=ptr;

display(head);
}

You might also like