Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
44 views3 pages

Lab Program 9

The document contains a C program that implements a doubly linked list with operations to insert, delete, and display nodes. It defines a structure for the nodes and provides functions to manage the list. The main function allows users to interact with the list through a menu-driven interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views3 pages

Lab Program 9

The document contains a C program that implements a doubly linked list with operations to insert, delete, and display nodes. It defines a structure for the nodes and provides functions to manage the list. The main function allows users to interact with the list through a menu-driven interface.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1

#include<stdio.h>

#include<stdlib.h>

struct node

int info;

struct node *llink;

struct node*rlink;

};

typedef struct node *NODE;

NODE first=NULL;

NODE insert_begin(NODE first)

NODE temp;

int item;

printf("enter thde value\n");

scanf("%d",&item);

temp=(NODE) malloc(sizeof(NODE));

if(temp==NULL)

printf("out of memory n");

exit(0);

temp->info=item;

temp->rlink=first;

temp->llink=NULL;

if(first!=NULL)

first->llink=temp;

printf("%d is inserted\n",temp->info);

first=temp;

return first;
2

NODE delete_begin(NODE first)

NODE cur;

if(first==NULL)

printf("list is emty\n");

return first;

cur=first;

first=first->rlink;

if(first!=NULL);

first->llink=NULL;

printf("%d is deleted\n",cur->info);

free(cur);

return first;

NODE display(NODE first)

NODE cur;

if(first==NULL)

printf("list is empty\n");

return first;

cur=first;

printf("content of the list are \n");

while(cur!=NULL)

printf("%d\t",cur->info);

cur=cur->rlink;}
3

printf("\n");

return first;

int main()

int option;

do

printf("\n doubly linked list opertion\n");

printf("1:insert\t2:delete\t3:display\t4:exit\n");

printf("enter the option:");

scanf("%d",&option);

switch(option)

case 1:first=insert_begin(first);

break;

case 2:first=delete_begin(first);

break;

case 3:first=display(first);

break;

case 4:break;

}while(option!=4);

You might also like