i have this as my code anyone to help me get the sum of the likned list and the the largerst value in the linked list....i have an error oputput

Code:
int sum(nd **head){

  nd *p;
  p=*head;
  while(p!=NULL)
  {

    p=p->next;
    return p->x+p->x;
  }
}
Code:
int locate(nd **head,int num){

  nd *p;
  p=*head;
  while(p!=NULL)
  {

    p=p->next;
    if(num==p->x)
    return 1;
    else
    return 0;
  }
}