WAP to search any node from double linked list


/*WAP to search any node from double linked list*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct node
{
 int data;
 struct node *llink;
 struct node *rlink;
};
typedef struct node node;
void search(node *);

void main()
{
 node *header=NULL;
 int n;
 clrscr();
    search(header);
 
 getch();
}

void search(node *temphead)
{
 int key,found=0;
 printf("Enter number you want to find:");
 scanf("%d",&key);
 while(temphead!=NULL)
 {

  if(temphead->data==key)
  {
   printf("\nSearch is sucessfull");
   found+=1;
   break;
  }
  temphead=temphead->rlink;
 }
 if(found==0)
 {
  printf("Search is unsucessfull");
 }
}

No comments:

Post a Comment