i am not able to search pls check it and send solution
#include
#include
struct node
{
int data;
struct node * next;
};
struct node * head=NULL;
struct node * tail=NULL;
struct node * newnode;
struct node * createnode()
{
struct node * s;
s=(struct node *)malloc(sizeof(struct node));
return s;
}
void insert(int data)
{
newnode=createnode();
newnode->data=data;
newnode->next=NULL;
if(head==NULL)
{
head=newnode;
tail=newnode;
}
else
{
tail->next=newnode;
tail=newnode;
}
}
void random()
{
int data,pos,i;
struct node * r,*s;
r=head;
s=createnode();
printf("Enter the data you want to enter in the list\n");
scanf("%d",&data);
printf("Enter the position on which you want ti enter the data\n");
scanf("%d",&pos);
s->data=data;
for(i=1;i
{
r=r->next;
}
s->next=r->next;
r->next=s;
}
void del()
{
int i,pos;
struct node* r,*s;
r=head;
s=createnode();
printf("Enter the position at which you want to delete the data\n");
scanf("%d",&pos);
for(i=1;i
{
r=r->next;
}
s=r->next;
r->next=r->next->next;
free(s);
}
void display()
{
while(head!=NULL)
{
printf("Data=%d\n",head->data);
head=head->next;
}
}
void search(int a)
{
while(head!=NULL)
{
if(head->data==a)
{
printf("Item found\n");
return ;
}
head=head->next;
}
printf("Item not found\n");
}
int main()
{
int i,n,data,k;
printf("Enter the no of the elements in the list\n");
scanf("%d",&n);
printf("Enter the data in the list \n");
for(i=1;i<=n;i++)
{
scanf("%d",&data);
insert(data);
}
printf("The entered list is :-\n");
display();
printf("Enter the item to search\n");
scanf("%d",&k);
search(k);
return 0;
}
Answers
Answered by
0
Please bhai or behan ase question na bheje.
Similar questions