Professional Documents
Culture Documents
h>
#include<conio.h>
#include<alloc.h>
#include<stdlib.h>
struct node
{
int data;
struct node *next;
}*start=NULL;
void create()
{
char ch;
do
{
struct node *new_node,*current;
new_node=(struct node*)malloc(sizeof(struct node));
printf("\nenter the data");
scanf("%d",&new_node->data);
new_node->next=NULL;
if(start==NULL)
{
start=new_node;
current=new_node;
}
else
{
current->next=new_node;
current=new_node;
}
printf("\ndo you want to create another:");
ch=getche();
}while(ch=='y');
}
void display()
{
struct node *new_node;
printf("\nThe linked list:");
new_node=start;
while(new_node!=NULL)
{
printf("%d--->",new_node->data);
new_node=new_node->next;
}
printf("NULL");
}
void search(int x)
{
int count=0;
{
struct node *q=start;
while(q->next->next!=NULL)
q=q->next;
node *temp=q->next;
q->next=NULL;
delete temp;
printf("\ndeleted successfully");
}
}
/*void del(int c)
{
}*/
void main()
{
int a;
clrscr();
create();
display();
reverse();
display();
search(a);
display();
del_first();
del_last();
display();
printf("\nenter the value of search");
scanf("%d",&a);
display();
getch();
}