Answered step by step
Verified Expert Solution
Link Copied!

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:

image text in transcribed

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

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_2

Step: 3

blur-text-image_3

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

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

4-1. What is meant by the term you attitude? [LO-1]

Answered: 1 week ago