I have two functions that finds sum of a very huge linked list.And recursive one does not give the true answer. (I have given the actual sum. So I know if the output is true or not)
My code:
float sum_linkedlist(numlist *head) {
if(head!=NULL)
return sum_linkedlist(head->next) + head->data;
else
return 0;
}
I cannot find what is wrong with my code.Can somebody help me?