Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 continueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started