Can anyone please help me to find the sum in the linked list. I have written codes to insert and remove numbers from lists but I have no idea how to calculate the sum.
void List::insert( const double &value )
{
ListNode *newPtr = getNewNode( value );
if ( isEmpty() )
firstPtr = lastPtr = newPtr;
else
{
newPtr->nextPtr = firstPtr;
firstPtr = newPtr;
}
}