Question: I need to write the following functions in list.cpp, add function prototypes for them to list.h and invoke the functions in main.cpp. It should label

I need to write the following functions in list.cpp, add function prototypes for them to list.h and invoke the functions in main.cpp. It should label the output of your test, such as the list after insertion: etc. Thanks!

int sumOfList(node * head)

~compute and return the sum of integers in the linear linked list.

void insert(node *& head, int position, int newInt)

~insert newInt at index position where index starts with 0.

// list.h

#include #include #include

struct node { int data; node * next; };

/* These functions are already written and can be called to test out your code */ void build(node * & head); //supplied void display(node * head); //supplied void destroy(node * &head); //supplied void duplicate(node * & new_copy); //provides a duplicate copy of the list

/* *****************YOUR TURN! ******************************** */ //Write your function prototype here: //

#endif

//main.cpp

#include "list.h" using namespace std;

int main() { node * head = NULL; build(head); display(head);

//PLEASE PUT YOUR CODE HERE to call the function assigned

display(head); destroy(head);

return 0; }

// list.cpp #include "list.h"

//put the implementation of your assigned functions here ~

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!