0% found this document useful (0 votes)
13 views

Data Structure-7

The document defines a C program to implement a linked list data structure to store and manage student records. It defines a node structure to store student data and pointer to next node. Functions are defined to create the list, insert and delete nodes from beginning and end of list, and display the list. The main function uses a menu to call these functions and allows the user to continuously add, remove and view student records in the linked list.

Uploaded by

B AB
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Data Structure-7

The document defines a C program to implement a linked list data structure to store and manage student records. It defines a node structure to store student data and pointer to next node. Functions are defined to create the list, insert and delete nodes from beginning and end of list, and display the list. The main function uses a menu to call these functions and allows the user to continuously add, remove and view student records in the linked list.

Uploaded by

B AB
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

#include<stdio.

h>

#include<conio.h>

#include<stdlib.h>

struct node

char usn[20],name[20],branch[10],phone[11];

int sem;

struct node *next;

};

typedef struct node *NODE;

NODE temp, head=NULL;

NODE getnode()

NODE temp;

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

temp->next=NULL;

printf("\n Enter USN, Name, branch, phone number and semester :");

scanf("%s%s%s%s%d",temp->usn,temp->name, temp->branch, temp->phone, &temp->sem);

return temp;

void insert_beg()

NODE temp=getnode();

if(head != NULL)

temp->next=head;

head=temp;

}
void create()

int n,i=0;

printf("Enter the number of students \n");

scanf("%d",&n);

for(i=1;i<=n;i++)

insert_beg();

void del_beg()

NODE tt=head;

if(head==NULL)

printf("\n No nodes to delete ");

else

if(head->next==NULL)

head=NULL;

else

head=head->next;

free(tt);

void insert_end()
{

NODE temp=getnode();

NODE tt;

if(head==NULL)

head=temp;

else

for(tt=head;tt->next!=NULL;tt=tt->next)

{ }

tt->next=temp;

void del_end()

NODE tt,p;

if(head==NULL)

printf("\n No Nodes to delete \n");

else

if(head->next==NULL)

head=NULL;

else

for(tt=head;tt->next->next!=NULL;tt=tt->next)

p=tt->next;

tt->next=NULL;

free(p);

}
}

void disp()

NODE tt;

int c=0;

if(head==NULL)

printf("the student detail is NULL and count is ZERO");

else

printf("\n USN\t Name\t Branch\t Ph.No \tSem \n");

printf("\n***********************************************************\n");

for(tt=head;tt!=NULL;tt=tt->next)

c++;

printf("\n %s\t%s\t%s\t%s\t%d",tt->usn,tt->name,tt->branch,tt->phone,tt->sem);

printf("\n Student count is %d\n",c);

void main()

int ch;

while(1)

{
printf("\n1.create 2.insert_beg 3.insert_end 4.del_beg 5.del_end 6.Display Any other key to
exit\n");

printf("\n\nEnter Your Choice: ");

scanf("%d",&ch);

switch(ch)

case 1:create();

break;

case 2:insert_beg();

break;

case 3: insert_end();

break;

case 4: del_beg();

break;

case 5:del_end();

break;

case 6:disp();

break;

default: exit(0);

You might also like