COSC 1437 Review Final Exam
Questions and Answers27
420 - ANSWERS-int puzzle(int start, int end)
{
if (start > end)
return start - end;
else if (start == end)
return start + end;
else
return end * puzzle(start + 1, end - 1);
}
Consider the accompanying definition of a recursive function. What is the output of the
following statement?
cout << puzzle(3, 7) << endl;
indirect - ANSWERS-Tracing through ____ recursion is more tedious than tracing other recursive
forms.
Statements in Lines 7-11 - ANSWERS-void printNum(int num) //Line 1
{ //Line 2
if (n < 0) //Line 3
,cout << "Num is negative" << endl; //Line 4
else if (num == 0) //Line 5
cout << "Num is zero" << endl; //Line 6
else //Line 7
{ //Line 8
cout << num << " "; //Line 9
printNum(num - 1); //Line 10
} //Line 11
} //Line 12
Consider the accompanying definition of a recursive function. Which of the statements
represent the general case?
10 - ANSWERS-int recFunc(int num)
{
if (num >= 10)
return 10;
else
return num * recFunc(num + 1);
}
Consider the accompanying definition of a recursive function. What is the output of the
following statement?
cout << recFunc(10) << endl;
static - ANSWERS-In ____ binding, the necessary code to call a specific function is generated by
the compiler.
, shallow - ANSWERS-In a ____ copy, two or more pointers of the same type point to the same
memory.
False - ANSWERS-[T/F] In C++, the dot operator has a lower precedence than the dereferencing
operator.
new - ANSWERS-The C++ operator ____ is used to create dynamic variables.
* - ANSWERS-In C++, you declare a pointer variable by using the ____ symb
43, 43 - ANSWERS-What is the output of the following code?
int *p;
int x;
x = 76;
p = &x;
*p = 43;
cout << x << ", " << *p << endl;
Increment - ANSWERS-Which of the following arithmetic operations is allowed on pointer
variables?
& - ANSWERS-In C++, ____ is called the address of operator.
*board[6] - ANSWERS-The statement that declares board to be an array of six pointers wherein
each pointer is of type int is: int ____________________;
Questions and Answers27
420 - ANSWERS-int puzzle(int start, int end)
{
if (start > end)
return start - end;
else if (start == end)
return start + end;
else
return end * puzzle(start + 1, end - 1);
}
Consider the accompanying definition of a recursive function. What is the output of the
following statement?
cout << puzzle(3, 7) << endl;
indirect - ANSWERS-Tracing through ____ recursion is more tedious than tracing other recursive
forms.
Statements in Lines 7-11 - ANSWERS-void printNum(int num) //Line 1
{ //Line 2
if (n < 0) //Line 3
,cout << "Num is negative" << endl; //Line 4
else if (num == 0) //Line 5
cout << "Num is zero" << endl; //Line 6
else //Line 7
{ //Line 8
cout << num << " "; //Line 9
printNum(num - 1); //Line 10
} //Line 11
} //Line 12
Consider the accompanying definition of a recursive function. Which of the statements
represent the general case?
10 - ANSWERS-int recFunc(int num)
{
if (num >= 10)
return 10;
else
return num * recFunc(num + 1);
}
Consider the accompanying definition of a recursive function. What is the output of the
following statement?
cout << recFunc(10) << endl;
static - ANSWERS-In ____ binding, the necessary code to call a specific function is generated by
the compiler.
, shallow - ANSWERS-In a ____ copy, two or more pointers of the same type point to the same
memory.
False - ANSWERS-[T/F] In C++, the dot operator has a lower precedence than the dereferencing
operator.
new - ANSWERS-The C++ operator ____ is used to create dynamic variables.
* - ANSWERS-In C++, you declare a pointer variable by using the ____ symb
43, 43 - ANSWERS-What is the output of the following code?
int *p;
int x;
x = 76;
p = &x;
*p = 43;
cout << x << ", " << *p << endl;
Increment - ANSWERS-Which of the following arithmetic operations is allowed on pointer
variables?
& - ANSWERS-In C++, ____ is called the address of operator.
*board[6] - ANSWERS-The statement that declares board to be an array of six pointers wherein
each pointer is of type int is: int ____________________;