Question: The following code is present: #include #include struct tax_node { char form; // tax form letter int version; // tax form number tax_node *next; //
The following code is present:
#include
#include
struct tax_node
{
char form; // tax form letter
int version; // tax form number
tax_node *next; // pointer to next node
};
typedef tax_node* tax_ptr;
using namespace std;
int main(int argc, char *argv[])
{
tax_ptr ptr1, ptr2, ptr3, mover;
ptr1 = new tax_node;
ptr1 -> form = 'w';
ptr1 -> version = 2;
cout << " ";
return 0;
}
Add the following code:
Create the following linked list (the node pointed to by ptr1 has already been created)
| ptr1 |
| form: w version: 2
|
| form: e version: 17
|
| form: d version: 6 |
Write a function prototype and definition for print_contents. print_contents takes a pointer to a node as its only parameter. It does not return a value. The function goes to a new line on output and prints the information in the node referenced by the pointer. For example if the following code was executed for the above example:
print_contents (ptr2);
The function would print:
e17
Write a loop in main that controls a pointer moving through the given list starting at ptr1. For each element of the list, print_contents should be called to print that elements information. Even though we know that the list in the example is three elements, the loop should work for any size list.
Step by Step Solution
There are 3 Steps involved in it
To solve this problem you need to complete two main tasks Create the linked list with three nodes Implement the printcontents function and iterate ove... View full answer
Get step-by-step solutions from verified subject matter experts
