Question: Well documented program, telling me what the program is supposed to do.The style should be the one either used in class or by the book

Well documented program, telling me what the program is supposed to do.The style should be the one either used in class or by the book (that is loops designs, explicit choice of variable names, well defined CONSTANT). Avoid using numbers where you can use named constant.Your code should be clear and easy to follow, your main function should be as simple as possible.The following program creates a linked list with three names:

#include

#include

using namespace std;

struct Node

{

string name;

Node *link;

};

typedef Node* NodePtr;

int main(int argc, char** argv) {

NodePtr listPtr, tempPtr;

listPtr = new Node;

listPtr->name = "Emily";

tempPtr = new Node;

tempPtr-> name = "James";

listPtr->link = tempPtr;

tempPtr->link = new Node;

tempPtr = tempPtr->link;

tempPtr -> name = "Joules";

tempPtr -> link = NULL;

//do your work here.

return 0;

}

Add code to the main function that:

  1. Outputs in order all names in the list.

That is you should have something like:

Emily

James

Joules

  1. Insert the name Joshua in the list after James then outputs the modified list.

That is you should have something like:

Emily

James

Joshua

Joules

  1. Delete the node with Joules then outputs the modified list.

That is you should get something like

Emily

James

Joshua

  1. Deletes all nodes in the list.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!