Question

PART 1 1. (TCO 1) For the values given, what will c contain after
executing the following? int a = 9, b = 4, c = -2; c *= ++a % b;
(Points : 6) 4 -4 -2 2 2. (TCO 2) Which statement outputs a double
value in a field of nine characters with three digits after the
decimal point? (Points : 6) cout << 9chars << 3digits
<< 1.2345678; cout << fixed << setprecision(9)
<< 1.2345; cout << setprecision(9) << setw(3)
<< 1.2345; cout << setprecision(3) << setw(9)
<< 1.2345678; 3. (TCO 10) For readability, variable names
should be (Points : 6) short and only use lower case letters. a
random mix of letters and numbers for security reasons. very long
and complex to assure uniqueness of each name. indicative of what
value is being stored in the variable. 4.(TCO 3) What is the value
of beta after the following code executes if the input is 1? int
beta; cin >> beta; switch(beta) { case 3: beta += 3; case 1:
beta++; case 5: beta += 5; case 4: beta += 4; } (Points : 6) 14 7 2
11 5.(TCO 4) How many times does the following loop body execute?
int count = 52; for(int i = 0; i <= 26; i++) { cout <<
count << endl; --count; } (Points : 6) 26 52 27 None of the
above 6. (TCO 8) Statements in your code which do not adhere to the
syntax rules of the language lead to (Points : 6) runtime errors.
linker errors. compiler errors. All of the above 7. (TCO 8) When a
program is stopped at a breakpoint, you can use the debugger to
(Points : 6) examine program variables. change the value of program
variables. set new breakpoints or clear existing breakpoints. All
of the above 8. (TCO 9) Testing repetition statements (Points : 6)
must validate that a loop repeats the correct number of times.
controlled by complex conditionals can involve many test cases.
must have a test case for each condition which terminates the loop.
All of the above 9. (TCO 9) Black box testing (Points : 6) is done
without any knowledge of how a program is implemented. is based on
the problem statement and the requirements which specify how the
solution must behave. is not concerned with testing every execution
path through the program code. All of the above 10. (TCO 5) It is
necessary to pass by reference when a function (Points : 6) uses
its input parameters in calculations. is returning more than one
result. treats its input parameters as local variables. All of the
above 11. (TCO 5) When should you use reference variables as
function parameters? (Points : 6) When the value of the actual
parameter needs to be changed When you want to return one value
from the function When you want the function to process a copy of
the data None of the above 12. (TCO 6) An array is a data type that
contains _______. (Points : 6) 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 PART 2 1. (TCO 5) A return statement causes execution
of a function to (Points : 6) return to the top of the loop. return
to the top of main. return to the top of the function. terminate
and return to where the function was called. 2. (TCO 5) Which of
the following statements call the following function correctly? int
MultiplyValues ( int, int ); (Points : 6) int a = MultiplyValues(
int x, int y ); int a = MultiplyValues( 10, 20 ); int d =
MultiplyValues( int 10, int 20 ); All of the above 3.(TCO 5) The
code below is an example of what type of function? int abs(int num)
{ if (num == 0) num = -num; return num; } (Points : 6)
Value-returning Void Subroutine None of the above 4. (TCO 6) What
is the range of valid subscripts for the following array? char
name[99]; (Points : 6) 1 to 99 0 to 98 1 to 98 0 to 99 5. (TCO 6)
Given the following array declaration, if the array is stored
starting at address 5000, what is the output of the following
statement? Assume the code is for a 32 bit processor such as a
Pentium. int data[25] = {0}; cout << &data[20] <<
endl; (Points : 6) 0.0 5020 5080 unknown 6.(TCO 6) What does the
following function do? double calc ( double data[ ], int size ) {
double s = 0; for(int i = 0; i < size; i++) { s += data[i]; }
return(s / size); } (Points : 6) Returns the sum of all the values
in the data array Does nothing because the data array does not
exist Fails because the size of the array is not known Returns the
average of the values in the data array 7. (TCO 6) foo contains
_______. double foo[500] = {0.0}; (Points : 6) 500 double values
499 double values one double value of 0.0 None of the above 8. (TCO
6) What will the third statement in the following code snippet do?
const int MAX = 500; double foo[MAX] = {0.0}; foo[MAX] = 1.1;
(Points : 6) assign the value 1.1 to the last array element. it
compiles but causes a run-time error. cause a compiler error. None
of the above 9. (TCO 5) A variable declared before all blocks in a
program is (Points : 6) visible to all functions defined in the
program. visible only to main. visible only to the first block
after it is declared. not visible to any functions; it will cause a
compile error. 10. (TCO 7) A C-Style string which is not null
terminated will (Points : 6) cause a compiler error. cause a
run-time error when processed by the strcpy function. cause a
linker error. produce a correct result when processed by the strlen
function. 11. (TCO 7) Which of the following correctly initializes
the name array with the name Jack Jones? (Points : 6) char name[15]
= "Jack Jones"; char name[ ] = "Jack Jones"; char name[ ] = {'J',
'a', 'c', 'k', ' ', 'J', 'o', 'n', 'e', 's', '\0'}; All of the
above PART 3 1(TCO 7) Given the following string variables, write a
statement that would add str2 to the end of str1. Do not use an
assignment statement to do this. string str1 = "Here is an ";
string str2 = "example string"; (Points : 6) 2. (TCO 7) Given the
following string variable, write a statement that would locate the
position of "string" in the str1 variable and store the result in
an int variable named pos. string str1 = "Here is an example
string"; (Points : 6) 3. (TCO 7) Create an output format statement
which would generate lines in the table which appear as shown
below. The Element Name Field displays an element name contained in
the name variable. YYY displays an integer value from the anum
variable which ranges from 1 thru 109 and should be left justified.
XXX.XXXX displays an atomic weight value from the aweight variable
which ranges from 1.0000 to 268.0000 and should be right justified.
Use the variables shown below in your output statements. Element
Name Field..YYY....XXX.XXXX char name[15]; int anum; double
aweight; (Points : 6) PART 4 1. (TCO 6) Write a function to have a
user enter some number of integers into an array. The integer
values must be between -100 and +100 inclusive (+100 and -100
should be accepted as valid inputs). The integer array and the size
of the array are passed into the function through parameters. Do
not worry about includes. This is only a function, so there is no
main routine. The function should fill the array with valid inputs.
For invalid input values, inform the user of the error, but do not
count that as a valid input. PART 5 1. (TCO 7) Write a function
that takes a C string as an input and counts the number of vowels
in the C string. Vowels must include both upper and lower case a,
e, i, o, u, and y. You are not allowed to use any other functions
to do this. Do not write a main function. Your function does not do
any cin or cout. Remember, C strings are terminated with the '\0'
character. Make sure to properly format all your code. 2. (TCO 7)
Write a function which takes two string variables (not C strings)
as inputs and compares them. If they are equal, the function should
return 0. If the first string is less than the second string,
return a negative number. If the first string is greater than the
second string, return a positive number. You are not allowed to use
the compare method of the string data type. You must use the
comparison operators. Do not write a main function. Your function
does not do any cin or cout. Make sure to properly format all your
code.