0% found this document useful (0 votes)
2 views2 pages

CDLL 3

The document contains C code for creating and displaying a circular doubly linked list (CDLL). It defines a function to insert a new node into the list and another function to display the values of the nodes. The code includes memory allocation, node linking, and traversal logic for the CDLL.

Uploaded by

arpitagaikwad209
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)
2 views2 pages

CDLL 3

The document contains C code for creating and displaying a circular doubly linked list (CDLL). It defines a function to insert a new node into the list and another function to display the values of the nodes. The code includes memory allocation, node linking, and traversal logic for the CDLL.

Uploaded by

arpitagaikwad209
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/ 2

struct node * Create_CDLL( struct node *h)

{
struct node *nn,*curr;
int item;
nn = (struct node *) malloc(sizeof(struct node));
printf("\nEnter value");
scanf("%d",&nn->info);
nn-> next = NULL;
nn-> prev = NULL;
if(h == NULL)
{
h =nn;
nn-> next = h;
nn -> prev = h;
}
else
{
curr= h;
while(curr->next !=h)
{
curr = curr->next;
}
curr->next = nn;
nn -> prev=curr;
h -> prev = nn;
nn -> next = h;
}

printf("\nnode inserted\n");
return h;
}

void display()
{

curr=h;

printf("\n printing values ... \n");

while( curr -> next != h)


{

printf("%d\n", curr -> data);


curr = curr -> next;
}
printf("%d\n", curr -> data);
}

void display()
{

curr=h;

printf("\n printing values ... \n");

do
{

printf("%d\n", curr -> data);


curr = curr -> next;
}
while( curr != h);
}

You might also like