Test I, CSCI 230, Spring 2022


  1. Basic Data Types
    1. [4 points] Describe the internal and external representations of a character.
    2. [5 points] Write a complete c++ function that takes a character and shifts it to the right three characters (a->d, b->e, ..., x->a, y->b, z->c) you should NOT write a huge case, or if-else-if statement.
  2. Typedef/Using
    1. [2 points] Why would a programmer provide a new name for a type?
    2. [2 points] The book tells us that the string header file performs the following
      typedef std::size_t size_type; 
      What does this line do?
    3. [2 points] Provide the corresponding using statement for the above typedef statement.
  3. Enumerations
    1. [4 points] Describe a situation where a programmer should declare an enumerated type.
    2. [4 points] Give the code to declare a strong enumerated type to hold the seasons of the year (winter, spring, summer, fall) as a SeasonT. Include NONE as the last season.
    3. [5 points] Write a function which given a SeasonT, returns the next season in order. If the season is NONE, return NONE.
  4. Compiling with Multiple Files: Practice
    1. [2 points] What should be placed in a header file?
    2. [2 points] What should be placed in an implementation file?
    3. [2 points] Why should using namespace std; not be placed in a header file?
    4. [4 points] What is the purpose of the guards in a header file? Give the syntax for at least one guard method.
  5. Compiling with Multiple Files: Theory
    1. [9 points[ Describe the function of the following parts of a compiler. Include the input and output for each part.
      • Preprocessor
      • Compiler Proper
      • Linker
    2. [3 points] Draw a diagram that shows the relationship between these compiler components.