Test 2, CSCI 130, Fall 2011

  1. [4 points] List the different integer types, describe the relationship between these types.
  2. [3 points] Describe the advantages of using a named constant over a literal value in a program.
  3. [3 points] Describe the floating point type.
  4. [2 points] What does the ++ operator do? You may describe it's use as a prefix or postfix operator.
  5. [8 points] Stream Manipulators
    1. What is a stream manipulator?
    2. Give an example of a stream manipulator including syntax.
    3. Describe what that stream manipulator does.
    4. Give an example of code which employs this manipulator.
  6. [6 points] Describe each of the following string operators, include syntax, function and an example of use.
    1. find
    2. substr
  7. [6 points]Stream extraction operators.
    1. Describe the operation of the steam extraction operator.
    2. Describe how the stream extraction operator deals with integers.
    3. Describe how the stream extraction operator deals with strings.
  8. [8 points points] I/O streams.
    1. Describe the purpose of the data types ifstream and ofstream
    2. Describe the syntax and behavior of the fstream functions .open() and .close()
  9. [ 5 points] A file contains a customer's shoe size, an integer on the first line and the description of the shoe they wish to purchase on the next line. The description may contain spaces. Using the following function prototype, build a function which will open the file provided in filename, read in and store the size and description in the associated variables.
    void GetRequestFromFile(string fileName, int & shoeSize, string & shoeDescription);
  10. [5 points] Describe functional decomposition.