{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

eecs280sp13_MidtermExam - uniqname EECS280MidtermExam...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
uniqname: _________________________ EECS 280 Midterm Exam Spring 2013 This is a closed­book exam. There are 5 problems on 15 pages. Read the entire exam through before you begin working. Work on those problems you find easiest first. Read each question carefully, and note all that is required of you. Keep your answers clear and concise, and state all of your assumptions carefully. Write your answers in the space provided. Write your uniqname on the line provided at the top of each page. You are to abide by the University of Michigan/Engineering honor code. Please sign below to signify that you have kept the honor code pledge: I have neither given nor received aid on this exam, nor have I concealed any violations of the Honor Code. Signature: _________________________________________ Name: _________________________________________ Uniqname: _________________________________________ University of Michigan Instructor: Andrew DeOrio EECS 280 Spring 2013 1/15
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
uniqname: _________________________ This page left intentionally blank. EECS 280 Spring 2013 2/15
Image of page 2
uniqname: _________________________ Do not write here. Problem 1 _________ out of 20 Problem 2 _________ out of 20 Problem 3 _________ out of 20 Problem 4 _________ out of 20 Problem 5 _________ out of 20 Total: _________ out of 100 EECS 280 Spring 2013 3/15
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
uniqname: _________________________ Problem 1: Short Answer 1.a) Which of these C++ main function declarations are valid? Circle 0 or more. 1. void main(int argc, char *argv[]) 2. int main (void) 3. int main(int argc, string *argv) 4. int main(int argc, char *argv) 5. static int main(void) 6. int main(int argc, char *argv[]) 1.b) Which of the following statements will increment a value in the array, and leave the pointer address unchanged? Circle 0 or more. int array[10]; // don’t circle this // initialize array elements … // don’t circle this int * ptr = array; // don’t circle this 1. *ptr++; 2. (*ptr)++; 3. *++ptr; 4. ++*ptr; 1.c) Which of these code snippets cause an infinite loop? Consider integer overflow as an “infinite loop”. Circle 0 or more. 1. for(int x = 0, y = 0; y <= 100; ++x); 2. do {i = 0;} while(i++); 3. do {} while(1%5&!­1); 4. for(char i = 0; i < 10; ­­i); 5. void func_call() { func_call(); } 1.d) On which lines of the following code snippet will a compile error occur? Circle 0 or more. 1. int a = 2; 2. double b = 4; 3. double *ptr = &a; 4. int &c = b; 5. *ptr = 5; 6. double *ptr2 = *(&ptr); EECS 280 Spring 2013 4/15
Image of page 4
uniqname: _________________________ 1.e) Which of the following statements are true? Circle 0 or more. 1. Indexing off the end of an array will always cause a segmentation fault. 2. When a pointer is used as a function argument, it must be passed by reference. 3. If ptr is of type const * int , ptr cannot be re­assigned to. 4. If ptr is of type const * int , * ptr cannot be re­assigned to. 5. If a pointer is declared, but not initialized, it is a null pointer. 6. If arr is an array of length 5, the expression *(arr++ + 3) == arr[3] evaluates to true . 1.f) Consider this recursive function: int someRecursive(int x, int y){ if (x == 0 && y == 0) { return 5; } //some return line } Which of the following lines could replace " //some return line " above and still keep the function tail recursive? Circle 0 or more.
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern