Welcome: This Is Presented by Mrs. Seema Sarvath From APS College of Arts and Science, NAMCC Department
This document presents a C program for constructing and manipulating a doubly linked list. The program allows the user to insert nodes at the front or after another node, delete nodes based on roll number, search for a node by roll number, and display all nodes. The main menu offers options to add records, delete a record, view records, search, or exit. Functions are defined to support each operation on the doubly linked list such as adding a node, deleting a node, displaying all nodes, and searching for a node.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
25 views
Welcome: This Is Presented by Mrs. Seema Sarvath From APS College of Arts and Science, NAMCC Department
This document presents a C program for constructing and manipulating a doubly linked list. The program allows the user to insert nodes at the front or after another node, delete nodes based on roll number, search for a node by roll number, and display all nodes. The main menu offers options to add records, delete a record, view records, search, or exit. Functions are defined to support each operation on the doubly linked list such as adding a node, deleting a node, displaying all nodes, and searching for a node.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9
WELCOME
This is presented by Mrs. Seema Sarvath
From APS College of Arts and Science, NAMCC Department 10. Using dynamic variables and pointers, Write a C program to construct a doubly linked list consisting of the following information in each node. Roll No (Integer), Name (Character String) .The Operations to be supported are: a. DLINSERT - Inserting a node in the front of the list and after a node. b. DLDELETE - Deleting the node based on Roll no. c. DLSEARCH - Searching a node based on Roll no. d. DLDISPLAY - Displaying all the nodes in the list.
This is presented by Mrs. Seema Sarvath
From APS College of Arts and Science, NAMCC Department #include<stdio.h> int ch; clrscr(); #include<conio.h> while (1) #include<stdlib.h> { struct info printf("\n OPerations On Doubly Linked { List"); char name[30]; printf("\n 1. To add records\n"); int rollno; printf("\n 2. To delete a record\n"); printf("\n 3. To view the records\n"); struct info *next; printf("\n 4. To Search \n"); struct info *prev; printf("\n 5.Exit"); }; printf("\n Enter your choice\n"); struct info *head=NULL,*temp,*disp; scanf("%d",&ch); void main() fflush(stdin); { switch(ch) { void addrecord(); case 1:addrecord(); void deleterecord(); break; void disrecord(); case 2:deleterecord(); void search(); break;
This is presented by Mrs. Seema Sarvath
From APS College of Arts and Science, NAMCC Department case 3: disrecord(); printf("\n Enter the Roll number:\n"); break; scanf("%d",&add->rollno); case 4:search(); fflush(stdin); break; if (head==NULL) case 5:exit(0); } { } head=add; } add->next=NULL; void addrecord() add->prev=NULL; { temp=add; struct info *add; } char ans='y'; else while (ans=='y') { { temp->next=add; add=(struct info*)malloc(sizeof(struct info)); printf("\n Enter the names:\n"); add->prev=temp; gets(add->name); add->next=NULL; fflush(stdin); temp=add; } This is presented by Mrs. Seema Sarvath From APS College of Arts and Science, NAMCC Department printf("\n Would you like to enter another fflush(stdin); name(y\\n): \n"); del=(struct info*)malloc(sizeof (struct ans = getchar(); info)); fflush(stdin); del=head->next; } if (head->rollno==teno) } { void deleterecord() printf("\n Head data cannot be { deleted\n"); struct info *del; return; int teno; } if (head==NULL) else { { printf("\n No records to delete \n" ); del=del->next; return; } } } printf("\n Enter the roll number to be printf("\nInvalid input\n"); deleted \n"); } scanf("%d",&teno);
This is presented by Mrs. Seema Sarvath
From APS College of Arts and Science, NAMCC Department void disrecord() void search() { { if (head==NULL) int rno; { if (head==NULL) printf("\n No records to view\n"); { return; printf("\n No records to view\n"); } return; for (disp=head;disp!=NULL;disp=disp- } >next) printf("\n enter the roll number to { search"); printf("\n\n Name : %s",disp->name ); scanf("%d",&rno); printf("\n\nRoll Number : %d",disp- for (disp=head;disp! >rollno); =NULL;disp=disp->next) } { } if(disp->rollno==rno) This is presented by Mrs. Seema Sarvath From APS College of Arts and Science, NAMCC Department { printf("\n\n Name : %s",disp- >name); printf("\n\n Roll Number : %d",disp->rollno);} else if(disp->rollno!=rno){ printf("\nRoll number does not exists\n"); break;}} }
OutPut:
This is presented by Mrs. Seema Sarvath
From APS College of Arts and Science, NAMCC Department THANK YOU This is presented by Mrs. Seema Sarvath From APS College of Arts and Science, NAMCC Department