how to get the sum of the link list and locate if it is in the list
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;
}
}
Re: how to get the sum of the link list and locate if it is in the list
Learn more about what the return statement does and you'll know why it doesn't work.