#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *next;
};
void main()
{
int i,n,pos,key,c=0;
struct node *newnode,*slist,*temp,*temp1;
clrscr();
slist=NULL;
printf("\nEnter no of node:");
scanf("%d",&n);
for(i=0;i
{
newnode=(struct node*)malloc(sizeof(struct node));
printf("\nEnter data:");
scanf("%d",&newnode->data);
newnode->next=NULL;
if(slist==NULL)
slist=temp=newnode;
else
{
temp->next=newnode;
temp=newnode;
}
} for(temp=slist;temp!=NULL;temp=temp->next)
{
printf("\ndata:%d",temp->data);
printf("\taddr:%d",&temp->data);
printf("\tnext:%d",temp->next);
} printf("\nEnter key:");
scanf("%d",&key);
for(temp=slist,i=0;i<=n;i++,temp=temp->next)
{
if(temp->data==key)
{
c=1;
pos=i;
printf("\n%d element found at %d position",key,pos+1);
break;
}
else
{
c=0;
continue;
}
} for(temp=slist;temp!=NULL;temp=temp->next)
{
if(c==1)
{
for(i=1;i
{
temp=temp->next;
}
temp1=temp->next;
temp->next=temp1->next;
free(temp1);
}
} printf("\n**RESULT AFTER DELETING %d ELEMENT",key);
for(temp=slist;temp!=NULL;temp=temp->next)
{
printf("\ndata:%d",temp->data);
printf("\taddr:%d",&temp->data);
printf("\tnext:%d",temp->next);
} if(c==0)
printf("\n%d element doesn't found in the list",key);
getch();
}
/
Recent Posts
Posted on 2019-07-18
Posted on 2019-07-18
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-05-28
Posted on 2019-05-24
Posted on 2019-05-24
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23