CS 211 - 10/7/16 Exam 1 - Wednesday, 10/19/16 During lab, you will have to write and submit a C program. The program will use one of the following: - a queue implemented as a linked list - a queue implemented as a dynamic array - a stack implemented as a linked list - a stack implemented as a dynamic array There are 5 operations you should be aware of: - initialization - add value (push for stack, enQueue "addToEnd" for the queue) - get value (top for stack, front for the queue) - remove value (pop for stack, dequeue "removeFromFront" for the queue) - isEmpty() For the exam, you can - bring in your own computer or use one in the lab - use any existing code that you wish - use the internet - use any books, notes Main restriction: NO use of other people during the exam. ===================== char* getName() { char name[31]; ... return name; } char* getName2() { char* name = (char*) malloc (sizeof(char) * 31); ... return name; } // in main() char* word; word = getName(); // may cause problems doSomeOtherFunction(); printf ("%s", word); word = getName2(); // should be fine doSomeOtherFunction(); printf ("%s", word); ================================== struct LabEx { int storage; } // for the following Java Code // inst1.setStorage(5); //Call // public void setStorage(int s) // { // this.storage = s; // } // the "cooresponding C-ish" code is: void setStorage (struct LabEx* this , int s) { this->storage = s; } // the call in C would be "close to" struct LabEx* inst1; inst1 = (struct LabEx*) malloc ( sizeof(struct LabEx)); setStorage (inst1, 5);