Adobe Scan Oct 15, 2023
Adobe Scan Oct 15, 2023
h>
#include <stdio.h>
void create():
void display():
void insert_ begin():
void insert_end():
void insert_pos():
void delete_begin0:
void delete_end):
void delete_pos):
struct node
int info;
struct node "next:
While(1)
{
printf("Enter your choice:t'):
scanf("%d",&choice):
switch(choice)
case 1:
create):
break;
case 2:
display):
break;
case 3:
insert_Lbegin():
break;
case 4:
insert_end):
break;
case 5:
insert_pos):
break;
case 6:
delete_begin):
break;
case 7:
delete_end():
break;
case 8:
delete_pos):
break;
case 9:
exit(0):
break;
default:
printf('n Wrong Choice:n):
break;
Ilend of switch
) l end of while loop
return 0;
void create()
struct node temp.'ptr;
temp=(struct node ")malloc(sizeof(struct node)):
if(temp=-NULL)
printf(nOut of Memory Space:n"):
exit(0):
printf("nEnter the data value for the node:t');
scanf("%d",&temp->info):
temp->next=NULL;
if(start==NULL)
start=temp:
else
ptr=start;
while(ptr->next!=NULL)
ptr=ptr->next;
ptr->next=temp;
void display()
struct node *ptr:
if(start==NULL)
printf(nList is empty:n'):
return;
else
ptr=start:
printf('nThe List elements are:n);
while(ptr!=NULL)
printf("%dtptr->info ):
ptr=ptr->next;
)
void insert _begin)
struct node *temp:
temp=(struct node *)malloc(sizeof(struct node):
if(temp==NULL)
printf(nOut of Memory Space:n"):
return;
start=temp;
else
ptr=start;
while(ptr->next !=NULL)
ptr=ptr-»next;
ptr->next =temp:
void insertpos()
{
struct node "ptr,"temp:
int i,pos:
temp-(struct node *)malloc(sizeof(struct node)):
if(temp==NULL)
print('nOut of Memory Spacen"):
return;
else
{
for(i=0,ptr=start,i<pos-1,ji++) (ptr=ptr->next;
if(ptr==NULL)
printf('nPosition not found:[Handle with care<n'):
return;
)
temp->next =ptr->next;
ptr->next=temp:
void delete_begin)
struct node ptr:
if(ptr==NULL)
printf('nList is Empty:n");
return;
else
ptr=start;
start=start->next:
printf('nThe deleted element is :%dt'.ptr->info):
free(ptr):
void delete_end()
ptr=start;
for(i=0;i<pos,i++) ( temp=ptr; ptr=ptr->next;
if(ptr==NULL)
printf("nPosition not Found:n");
return;
temp->next =ptr->next
printf(nThe deleted element is:%dt".ptr->info ):
free(ptr);