Test I, CSCI 230, Spring 2016


A data type is defined in your book as A specific set of data values, along with a set of operations on those values.. Please keep this definition in mind when answering the following questions.
  1. Enumerated Types
    1. [3 points] Give the syntax for declaring an enumerated type.
    2. [3 points] Give the code required to declare an enumerated type which represents the basic geometric types point, line, square and cube. Where in the program does this declaration go?
    3. [2 points] Declare a variable of your type from part B. Where in the program does this declaration go?
    4. [4 points] Is an enumerated type a data type? Why or why not? Use the type declared in part B in your answer.

  2. Structures
    1. [2 points] What is a structured data type?
    2. [3 points] Give the syntax for declaring a struct
    3. [3 points] Give the code required to declare a structure which holds a string representing a name and an int representing an age. This structure holds a person. Where does this code go in a program?
    4. [2 points] Give the code required to declare a variable of the structure from part C.
    5. [1 points] Give the code needed to assign name field in the variable declared in part D the value bob "Bob" and the age field with the value 7.
    6. [1 point] What is the difference between the declaration in part C and the declaration in part D?

  3. Modular Compilation
      A program is split between three files. A main routine in main.c , a header file utils.h, and an implantation file utils.C.
    1. [7 points] Draw a diagram showing the process where these files will be compiled into a single executable. Place the files listed above, along with the following terms in your diagram where appropriate.
      • System Header Files
      • Library Files
      • Intermediate Source Code.
      • Object file
      • Executable.
    2. [3 points] Label your diagram, in all applicable locations, with the following processes:
      • Preprocessor
      • Compiler Proper
      • Linker

    Over Please

  4. Typedef
    1. [2 points] What does the typedef reserved word do?
    2. [1 point] Give the syntax for typedef.
    3. [1 point] Give an example of a typedef.
    4. [2 points] Why would a typedef be used in a program?

  5. Misc.
    1. [2 points] Describe the type of information which belongs in a header file.
    2. [4 points] What operations are supported on structures?
    3. [4 points] What operations are not supported on structures?