Test I, CSCI 230, Spring 2016
- The weight for each question is given.
- Use as much paper as you wish, but make your answers are legible.
- Please label your answers with the question number.
- Please answer each question thoughtfully and carefully.
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.
- Enumerated Types
- [3 points] Give the syntax for declaring an enumerated type.
- [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?
- [2 points] Declare a variable of your type from part B. Where in the program does this declaration go?
- [4 points] Is an enumerated type a data type? Why or why not? Use the type declared in part B in your answer.
- Structures
- [2 points] What is a structured data type?
- [3 points] Give the syntax for declaring a struct
- [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?
- [2 points] Give the code required to declare a variable of the structure from part C.
- [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.
- [1 point] What is the difference between the declaration in part C and the declaration in part D?
- 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.
- [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.
- [3 points] Label your diagram, in all applicable locations, with the following processes:
- Preprocessor
- Compiler Proper
- Linker
Over Please
- Typedef
- [2 points] What does the typedef reserved word do?
- [1 point] Give the syntax for typedef.
- [1 point] Give an example of a typedef.
- [2 points] Why would a typedef be used in a program?
- Misc.
- [2 points] Describe the type of information which belongs in a header file.
- [4 points] What operations are supported on structures?
- [4 points] What operations are not supported on structures?