I want to sum the nodes until 0 is reached and update the original linked list with the new values.
Note: it skips 0 until it reaches a number to calc sum or the end of the linked list.
Definition of node:
struct Node {
int data;
Node* next;
};
void updateLinkedList(Node* head)
{
Node* currentNode = head;
int temp = 0;
int sum = 0;
while (currentNode != NULL)
{
temp = currentNode->data;
while(temp != 0)
{
sum = sum + currentNode->data;
currentNode = currentNode->next;
}
}
}
I'm attempting to do the next thing:
User input linked list:
1 2 0 5 3 0 4
Updated Linked List:
3 8 4