Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Computer Science and Programming Prof. Gregory Safko Final Exam Student-submitted Review Questions Multiple Choice Questions: 1. Which of the following is the correct way to declare a multidimensional array? a. int baseball[2, 9]; b. int baseball[2][9]; c. int baseball(2, 9); d. int baseball(2)(9); 2 What is the proper way to declare a header file in a program where the header file is located outside of the compiler includes folder? a. #include <headerfile> b. #include "headerfile" c. #include <headerfile.h> d. #include "headerfile.h" 3. What is the imaginary number i equal to? a. -1 b. -1* sqrt(1) c. sqrt (-1) d. 3.14 4. Which will assign a random number between 6 and 50 to num? a. int num=rnd(45); b. int num=(rand()%(45+6)); c. int num=(rand(6)%45); d. int num=random e. int num = rand( ) %45 + 6; 5. All recursive functions have a. a. string object b. constructors c. base case d. mutators 6 All ______________________ have a base case. a. iterative functions b. recursive functions c. class methods d. complex numbers 7. Which of the following is true about Multi-Dimensional arrays? a. When declaring an array of local scope its content is undetermined until we store some values in it. b. Series of elements of the same type place consecutively in memory that can be individually referenced by adding an index to a unique name. c. A template class of sequence containers that arrange elements of a given type in a linear arrangement and allow fast random access to any element. d. a&b e. a&c Free Response/Open Ended Questions 1. Give an example of a switch statement where A, B, and C will return true and everything else would be false. Answer: switch(test) { case 'A': case 'B': case 'C': answer = true; break; default: answer = false; } 2. Declare the multidimensional array baseball in multiple choice question 1 as a vector. Answer: vector< vector<int> > baseball(9); 3. To make sure a header file is defined, what three lines of code would you place in your .h file? Answer: #ifndef HEADER_H #define HEADER_H #endif 4. Give two examples of queues? Answer: There are many examples, such as Waiting in line for movie tickets Getting on an escalator 5. Explain the difference between an Iterative Function and a Recursive Function. Answer: A recursive function is a function that calls itself. An iterative Function is a function that is used again and again, usually with a for or do, do/while loop control structure.