Question: 1. A function calling statement must supply arguments that: a. match the function header in number b. match the function header in number and order
1. A function calling statement must supply arguments that: a. match the function header in number b. match the function header in number and order c. match the function header in number, order, and data type d. match the function header in number, order, data type, and names e. match the function header in number, names, and data type
2. Which of the following appear in a function header? a. the function name, return type, and argument types b. the function name, return type, argument types and argument names c. the function name, return type, and argument names d. the function name and the supplied arguments
3. How does a function report its answer back to its calling (or boss) function? a. by altering or storing the result into one of the variables passed as an argument b. by altering or storing the result directly into the callers variable c. by cout ing the result to the screen d. by asking the user via an input function e. by executing a return statement with the answer
4. A function prototype does not have to __________. a. include argument names b. end with a semi-colon c. agree with the function header d. match with all calls of the function
5. What will be displayed by the following code?
int main() { int num = 3; fn(num); cout << num; return 0; } int fn( int n ) { n++; } a. The code will not display anything b. 3 c. 4 d. 5 e. There is not enough information provided to determine what will be displayed.
6. When the body of a function begins to execute what is true of its arguments? a. they must be declared as local variables in the function b. they must be initialized by the function before they are used c. they already have values provided by the calling function and are ready to be used d. the arguments must be #defined
7. A variable called score is declared in main(). main() calls a function UpdateScore to update the score. UpdateScore also has a variable called score. When a value is added to score in UpdateScore, the value of score in main() is also changed. a. true b. false
8. Prototype statements are placed before int main(). a. true b. false
9. The function header and the calling statement must contain the name and the data type of the arguments. a. true b. false
10. The statement int main() means that main is a function that takes no arguments, and returns an integer. a. true b. false
11. What is the subscript of the last element in the array Table if it is defined as follows? float Table[30]; a. 30 b. 31 c. 29 d. 0 e. none of the above
12. Which of the following statements (a-d) about Table is true?
float Table[] = { 0.9, 0.8, 0.7, 0.6 }; a. The definition for Table will cause an error because there is no value specified inside of the square brackets b. Table[1] contains the value 0.9 c. There are actually 5 values stored in Table - the four listed and a null terminator as the fifth element d. The definition for Table will cause an error because an array cannot be initialized when it is created e. All of the statement (a-d) are false
13. Which of the following "chunks" of C++ code will print the contents of an array called ar that has been defined to hold 25 integer values and has been initialized with 25 integer values? int i;
a) cout << ar[]; b. for( i = 0; i == 25; i++ ) cout << ar[i] << " "; c. for( i = 0; i < 25; i++ ) cout << ar[i] << " "; d. for( i = 0; i < 25; i++ ); cout << ar[i] << " ";
14. The following is a valid array definition.
int ar[]; a. true b. false
15. What will be displayed by the following code?
int main() { int num[5] = { 2, 4, 6, 8, 10 }; int i; fn(num); for( i = 0; i < 5; i++ ) cout << num[i] << ' '; return 0; } int fn( int n[] ) { n[3] = n[3] + 1; } a. The code will not display anything b. 2 4 6 8 10 c. 2 4 7 8 10 d. 2 4 6 9 10 e. There is not enough information provided to determine what will be displayed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
