Consider the following C++ statements: struct nodeType { int info; nodeType *link; }; nodeType *head, *p, *q, *newNode; newNode = new nodeType; 1. Write C++ statement to store 50 in the info field of the newNode. 2. Write C++ statement to set the link field of the newNode to NULL. 3. Write C++ statement to make head pointer points to newNode. 4. Write C++ statement to delete the first node in the linked list. (the first and the only node in the linked list that you just added it in the previous questions.)

Respuesta :

Answer:

1.

newNode ->info = 50;

2.

newNode ->link = NULL;

3.

head = newNode;

4.

delete head;

Explanation:

1.

The C++ statement newNode ->info = 50; will perform a function of storing the number 50 in the info field of the newNode.

2.

newNode ->link = NULL;

This above written code will simply perform one function, and that is to set the link field of the newNode to NULL.

3.

When this C++ code is written

head = newNode; it will produce the output of making head pointer points to newNode.

4.

delete head; this statement performs the function of deleting the first node in the linked list.