Test I, CSCI 230, Spring 2013
- The weight for each question is given.
- Use as much paper as you wish, but make your answers are legible.
- Please answer each question thoughtfully and carefully.
- [4 points] Describe functional decomposition.
- [4 points] Describe how a program composed of many functions is easier to debug and maintain.
- [2 points] What is object oriented design? (This is also called bottom up design)
- [2 points] Give the syntax for the typedef statement.
- [3 points] What is the purpose of the typedef statement?
- [3 points] Give the syntax for declaring an enumerated type.
- A popular child's game has a spinner which can have any of the following results: Body, Head, Antenna, Eye, Proboscis, Leg. You are implementing such a game and have decided to use an enumerated type to represent the spinner results.
- [2 points] Give the C++ code to declare this enumerated type.
- [5 points] Give the C++ code for a function which represents spinning this spinner. The function should return a random result of the spinner type. All results should be equally likely.
- [4 points] Give the C++ code for a function which takes a variable of the enumerated type and returns a string containing the associated word.
- [3 points] What is a structure (struct)?
- [3 points] Give the syntax for declaring a struct.
- [2 points] What is the difference between declaring a structure and defining a variable of that structure type?
- You are writing a program which employs names. A name consists of a first name, a middle initial, a last name and a title.
- [3 points] Give the C++ code to declare this structure.
- [5 points] Give the C++ code for a function which will print the contents of the structure you declared in part 1.
- [5 points] Give the C++ code for a function which will take an instance the structure in the first part as a parameter, and prompt the user for values for each of the features. The function should store the user's values in the parameter.