Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

ptr2

form: e

version: 17

ptr3

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions