CSCI 240 - Possible Questions for Quiz 5

  1. (2 points) main() is a function.

    1. true
    2. false
    3. it depends on how you define it
  2. (2 points) A function knows _______ about the calling code.

    1. something
    2. nothing
    3. everything
  3. (2 points) Every function must return a value.

    1. true
    2. false
  4. (2 points) It is legal and acceptable to have two local variables in two different functions with the same name and the same data type.

    1. true
    2. false
    3. only if they always have different values
    4. only if they always have the same value
  5. (2 points) 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

    1. no values
    2. at most 1 value
    3. 1 or more values
  6. (2 points) Write a function prototype for a function called findLarge. It takes two integers as its arguments and returns an integer.

  7. (2 points) Write a function header for a function called findLarge. It takes two integers as its arguments (named val1 and val2) and returns an integer.

  8. (2 points) Write a complete function called findLarge that will return the larger of two integers. It takes two integers (the values to be compared) as its arguments.

  9. (2 points) Write a complete function called calcTriArea that will calculate and return the area of a triangle. It takes two float/double values: the base and height as its arguments. The area of a triangle is one-half the base times the height.

  10. (2 points) A function exists called calc(). It takes two integer arguments and returns a real result. Assume the following declarations:

  11. int a = 4, b = 5;

    Write a single statement that will print the result of calling calc() with these arguments.

  12. (2 points) If a function takes two integer arguments it

    1. must return an int
    2. must return a numeric value of some kind
    3. can return any valid data type