SSL Certificate
  • Copy the credits field from the second node to the credits field in the first node
19.    Given the code definitions:
  struct courseRec {
string course;
int credits;
nodeRec* next;
nodeRec *listTop, *nodePtr;

used to create the following list:

Write the C++ code to do the following (declare any necessary variables):

a.  Copy the credits field from the second node to the credits field in the first node (3 pts).

b.  Create a new node containing the course "CS208", with 3 credits, and a NULL pointer (3 pts).

c.  Insert the new node into the list as the first node in the list (3 pts).

d.  Write a function to count the number of nodes in a list of this type (again, unknown length) 
and pass back the integer result (5 pts).

20.  Using the node declaration:

  struct nodeRec {
int data;
nodeRec* link;

nodeRec *head, *ptr;

a.  Given the above node and variable definitions, and the code:

head = NULL;

for (int count = 5; count <= 26; count += 7) 
ptr = new nodeRec;
ptr->data = count + 1;
ptr->link = head;
head = ptr;
What list does the above code create?  (3 points)
(Sample format for answer:    head  86  31  NULL) 

b.  Using the above node and variable definitions, suppose the following linked list was built:

    What is output by the code (3 pts):

    ptr = head->link;
    while (ptr != NULL) {
        if ( (ptr->value % 2) == 0 )
            cout << ptr->value << "  " << endl;
        ptr = ptr->link;

21. Given an stack of integers that starts out empty, the following operations are performed:

int x, y;
y =;
x =;

What are the values of x and y?  (3 pts)

22. Given:

    class foo
        int data;
        string description;
         int a (int num);
         void b (foo f) const;

    void c ();
    int d (int value);

Of the four functions defined above, which can alter the private member variables of the a foo object? (3 pts)

23. Given:

enum babyShoes {INFANT, BABY, TODDLER};
const int NUM_TYPES = 3;
const int NUM_SIZES = 5;

int numInStock [NUM_SIZES][NUM_TYPES];

  The numInStock array holds the number of shoes in stock, by size and type.  
So each cell will hold the count for one particular type, in a particular size.
  Assume sizes go from 0 to 4.

 Using the enumerated type values in your code, write the C++ code to store the fact that the store has 56 pairs of size 3 toddler shoes in stock. (3 pts)

Excellent Solution
*Instant Download

Write a review

Please login or register to review

Copy the credits field from the second node to the credits field in the first node

  • $9.99

*All your data are SECURED & ENCRYPTED using a valid, trusted server certificate (Comodo SSL) and we don't store credit card information on our servers and all Payments are SECURED & handled by Paypal.
SSL CertificatePaypal

Tags: c, programmingm, struct