Question: Create a program named list.cpp. In that program, add the following structure. struct ListNode { int value; ListNode * next; } In your main function,
Create a program named list.cpp. In that program, add the following structure.
struct ListNode
{
int value;
ListNode * next;
}
- In your main function, create three objects of type ListNode, a, b, c.
- Set the value member of a to be 3, b to 8 and c to 10.
- Make the next member of a point to b.
- Set the next member of b to c to NULL
- Write a function (or a member function of the class if prefer) that takes a ListNode* and prints out all the values in the linked list.
- Write a function (or a member function of the class if prefer) that calculates the length of a linked list and returns it.
void printNode(ListNode *);
int lengthList(ListNode *);
sample output:

Now, 3 8 10 are in the list. The total nunber of nodes in the list is 3 Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
