Final Exam CSCI 130 Fall 2013


  1. Functions
    1. [10 points] Give the outline of a program which includes a function. Include examples of, and clearly label each of the following.
      • Function Prototype
      • Function call (invocation)
      • Function definition
      • Parameter List
      • Arguments.
    2. [3 points] Describe the properties an argument and parameter must have in common.
    3. [6 points] Name and describe the two kinds of parameters. When should a programmer employ each kind of parameter?
  2. Scope/Lifetime
    1. [1 points] Define the scope of an identifier.
    2. [2 points] Describe the scope rules for C++.
    3. [2 points] What is a global variable and why should programmers avoid employing global variables?
    4. [1 points] What is the lifetime of a variable?
  3. [3 points] What is functional cohesion?
  4. Employing Functions
    1. [3 points] Why is repeated code a problem in a program?
    2. [2 points] How can programmers solve the problem of repeated code?
  5. [3 points] Write a function which takes an integer between 0 and 9 and returns the English name of that integer. For example, if the input is 5, the output should be "five".
  6. [4 points] Write a void function which takes a string and reverses the order of the characters in that string. For example, the string "Hello World!" would become "!dlroW olleH"
  7. [5 points] Write function which takes a string and returns true if the string is a perfect palindrome. A perfect palindrome reads the same in each direction, "able was I ere I saw elba" is a perfect palindrome, but "Race caR" is not. You may use the function from the previous question as part of your solution.
  8. [5 points] Write a program which reads a series of phrases from the file "sayings.dat". Each phrase occupies a single line. For each phrase, your program should print out "Perfect Palindrome" if the phrase is a perfect palindrome. You may use the code from the previous questions to solve this problem.