Test 2, Summer 2009


  1. (5 points) Describe functional decomposition.
  2. (5 points) What is pseudocode?
  3. (5 points) What is an algorithm?
  4. (5 points) What is a structure chart?

  5. (5 points) Describe how the terms from questions (1-4) are use in the program design process.

  6. (5 points) What is the flow of control of a program? How can the flow of control be altered?

  7. (10 points) Describe what happens when each of the following statements is executed.
    1. ifstream inFile;
    2. inFile.open("foo.data");
    3. inFile >> avar;
    4. if (inFile) {
    5. inFile.close();

  8. (5 points each) For each of the following:

    1. For loop
    2. While loop
    3. Do While loop
    4. If Then Else statement

  9. (15 points) The file, InputFile.dat contains only integers. Write a program which will compute the following:

  10. (10 points) Describe the function of, and the difference between each of the following methods for reading a string.
    • fileStream >> stringVar;
    • getline(fileStream, stringVar);
    • i = 0;
      stringVar  = "";
      do {
        fileStream.get(ch);
        if (!isspace(ch)) {
            stringVar = stringVar + ch;
        }
      } while (ch != '\n');
      	      
  11. (15 points) Write a program which will ask the user for two lower case letters and print all letters between the two letters. The order of the letters should be preserved (if the user enters a c, the output should be a b c, if the user enters c a, the output should be c b a.