Final Exam Form A, CSCI 130, Fall 2011


  1. Do While Statement
    1. [2 points] Give the syntax for the do while statement.
    2. [2 points] When is it most appropriate to use a do while statement?
    3. [6 points] Write a routine (using the function prototype below) which will require the user to input a between low and high. The user will enter integers, but not necessarily in range. Your routine should not exit until a valid value is obtained.
       
      int Get value(int low, int high);
      	   
  2. For Statement
    1. [2 points] Give the syntax of the for statement.
    2. [2 points] Give the flow of control of the for statement.
    3. [2 points] When is it appropriate to us a for statement?
    4. [4 points] Give a code segment (using a for statement) which will count from 10 to 100 by 5.
  3. Functions:
    1. [4 points] Describe how functions simplify the task of programming.
    2. [6 points] Describe how a formal parameter list and arguments must match.
    3. [6 points] Describe the difference between pass by value and pass by reference. Include a discussion of when each is appropriate.
    4. [4 points] What problems caused by global variables are overcome when using parameters?
  4. [5 points] Write a function which will count the number of letters, digits and other characters in a string.
  5. [5 points] Write a function which takes a string and returns true if the string is a palindrome. A palindrome is a phrase, which when spaces and punctuation are ignored, reads the same forward and backwards. "Madam I am Adam" and "racecar" are both palindromes.