Preview:
//iterative
Search(Node *p, int key){
  while(p!=NULL){
    if(key==p->data)
      return p;
    p= p->next;
  }
  return NULL;
}

//recursive
Node* Search(Node *p, int key){
  if(p==NULL)
    return NULL;
  if(key==p->data)
    return p;
  return Search(p->next, key);
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter