Lab 13: Picture Dynamic Memory

This lab is a paper-and-pencil lab. TAs will manually check your drawings on paper.

Draw the pictures representing each of the declarations below.  Each is worth ½ a point, for a maximum of 3.  

These problems build on each other, so in some cases a picture refers to something previously created. 

/* Lab 13: Picture Dynamic Memory

Objective: Draw Pictures of Computer Memory 

*/

#include<iostream>

using namespace std;

int main() {

    // 1.

    int numbers[5];

    //-------------

    // 2.    

    char words[3][10]; 

    //---------------- 

    // 3.

    int *pNumbers = new int[4];  

    //-------------------------

    // 4.

    char **pWords;

    pWords = new char*[3];

    for( int i=0; i<3; i++) {

        pWords[i] = new char[5];

    }

    //---------------------------

    // 5.

    //Assume we have:

    class Student{

        public:

            Student(){

                initials[0] = 'D'; 

                initials[1] = 'F'; 

                initials[2] = 'R';

                UIN = 12345;

            }

        private:

            char initials[3];   // Delano Franklin Roosevelt would be DFR

            long UIN;

    };

    // Now draw the following: 

    Student cs141[3];

    Student *pStudent = &cs141[2];

    Student *pOther = pStudent;

    //--------------------------------------

    //6.

    //Assume we have:

    struct Node {

        int data;

        Node *pNext;

    };

    // Now draw the following:

    Node n1;

    n1.data = 3;

    Node *pNode = new Node;

    pNode->data = 5;

    pNode->pNext = &n1;

    pNode->pNext->pNext = pNode;

    ///======================================

    return 0;

}