CSCI 240 - Quiz Questions - Week 6
1. (2) main() is a function.
a. true
b. false
c. it depends on how you define it
2. (2) A function knows _______ about the calling code.
a. something
b. nothing
c. everything
3. (2) Every function must return a value.
a. true
b. false
4. (2) It is legal and acceptable to have two local variables in two different
functions with the same name and the same data type.
a. true
b. false
c. only if they always have different values
d. only if they always have the same value
5. (2) With what we have learned so far about C++ functions, a function can directly (i.e. by itself, not as a
consequence of
an assignment statement in the calling function) alter
_____________ in the calling function
a. no values
b. at most 1 value
c. 1 or more values
6. (4) Write a complete function that will return the larger of two integers.
7. (4) Write a complete function that will return the area of a triangle given the base and altitude. Allow real values. The area of a triangle is one-half the base times the altitude.
8. (2) A function exists called calc(). It takes two integer arguments and returns a real result. Assume
int a = 4, b = 5;
Write a single statement that will print the result of calling calc() with these arguments.
9. (2) If a function takes two integer arguments it
a. must return an int
b. must return a numeric value of some kind
c. can return any valid data type