Final Test
Final Test
1. Which of the following is the correct function definition header for the getAge function
a. int getAge();
b. int getAge()
c. int Person:getAge()
d. int Person::getAge()
2. The line of code that will declare an array and initialize it is:
d. Nothing is returned
4. What is wrong with the following recursive function? It should print out an array
backwards.
If (start == size )
return;
else
a. Infinite recursion
d. Nothing
5. Which of the following would you use in a function prototype for a formal parameter
a. float[ ]
b. float [SIZE]
c. float&[ ]
d. const float [ ]
6. Given the following structure definition, what is the correct way to initialize a variable
called today?
struct DateType
int day;
int month;
int year;
a. DateType today(1,1,2000);
a. find all the stopping cases and the values if needed at that case.
b. find a recursive call that will lead towards one of the stopping cases.
8. What is the output of the following code, given in the definition below?
int a = 7, b = 12;
{
N = n - 2 * m;
m = 2 * m;
a. 7 -2
b. 7 12
c. 14 -2
d. 14 12
a. *p1 = value;
b. P1 = value;
c. p1=&value;
d. &p1 = *value;
a. When the parameter is carrying information into the function that does not have to
be returned.
b. When the parameter is carrying information into the function that may be changed
c. When the information is to be returned from the function using the parameter.
a. Equals operator
b. Assignments operator
c. Extraction operator
12. What is the output of the following code, given in the definition below?
int x =5, y = 2;
cout << x;
p = p * t;
return p + 1;
a) 5
b) 6
c) 10
d) 11