COMP 122 Final Exam Latest Version

COMP 122 Final Exam Latest Version

Author: Abraham Nolito


(TCO 1) For the values given, what will c contain after executing the following?
int a = 9, b = 4, c = -2;c *= ++a % b;
(TCO 2) Which statement outputs a double value in a field of nine characters with three digits after the decimal point?
(TCO 10) For readability, variable names should be
(TCO 3) What is the value of beta after the following code executes if the input is 5?
Int beta;
cin>> beta;
beta +=5;
beta +=5;
case 4:
beta +=4;
(TCO 4) How many times does the following loop body execute?
Int count=52
For(int i=26; i>=0; i=i-2)
-- count;
(TCO 8) Trying to access an array element beyond the end of the array can lead to an attempt to access an address outside your program's memory space which is a
(TCO 8) When a program is stopped at a breakpoint, you can use the debugger to

examine program variables.
change the value of program variables.
set new breakpoints or clear existing breakpoints.
All of the above

(TCO 9) White box testing
(TCO 9) When doing feature testing, _______.
(TCO 5) It is necessary to pass by reference when a function
(TCO 5) Arrays are always passed into a function by location because
(TCO 6) An array is a data type that contains _______.
a fixed number of elements
a set of values all of which are of the same type
values that must either be initialized when the array is declared or assigned at runtime
All of the above
(TCO 5) Place function prototypes before main() to
(TCO 5) What is the output of the following code?
void func(int x[])
x[0] = x[0] * 3;
x[1] = x[1] * 3;
x[2] = x[2] * 3;
int main()
int x[] = { 1, 2, 3 };
cout < x[0]="">< "="" "="">< x[1]="">< "="">< x[2]="">< endl;="">

(TCO 5) The function overloading feature of C++ enables _______.
(TCO 6) What is the range of valid subscripts for the following array?

double list[10];
(TCO 6) Given the following array declaration, if the array is stored starting at address 1000, what is the output of the following statement? Assume the code is for a 32 bit processor such as a Pentium.
double data[25] = {0.0};cout < &data[10]="">< endl;="">
(TCO 6) Given the following code which fills the array with values,

See More
Try a College Course Free

Sophia’s self-paced online courses are a great way to save time and money as you earn credits eligible for transfer to over 2,000 colleges and universities.*

Begin Free Trial
No credit card required

26 Sophia partners guarantee credit transfer.

226 Institutions have accepted or given pre-approval for credit transfer.

* The American Council on Education's College Credit Recommendation Service (ACE Credit®) has evaluated and recommended college credit for 21 of Sophia’s online courses. More than 2,000 colleges and universities consider ACE CREDIT recommendations in determining the applicability to their course and degree programs.