CS 216

Review for Second Quiz

  1. Variables known to several functions in C are called ___.
    1. common
    2. local
    3. global
    4. shared


  2. Each of the following is a storage class keyword, except which one?
    1. register
    2. local
    3. extern
    4. static


  3. A storage class in C does all of the following except
    1. controls which functions in a file have access to a variable.
    2. defines the data types that are possible for a variable.
    3. determines in how many places the same variables can be declared.
    4. determines how long the variable persists in memory.


  4. What scope do the variables jim and sandy have, given the statements:
    double names(double jim)
    {
    double sandy = 0.0;
    .....
    return sandy;
    }
    1. file
    2. block
    3. function prototype
    4. Both b and c are correct answers


  5. By default, variables declared in a function are ___.
    1. static
    2. register
    3. external
    4. automatic


  6. Automatic variables are initialized automatically to ___.
    1. 0
    2. 1
    3. -1
    4. They are never initialized automatically.


  7. External variables have ___ storage duration.
    1. block
    2. static
    3. automatic
    4. external


  8. If the keyword extern is used without a data type, the compiler interprets it as being of type ___.
    1. int
    2. void
    3. char
    4. float


  9. Static class variables have ___ scope but ___ storage duration.
    1. function, automatic
    2. block, external
    3. function, static
    4. block, static


  10. Which one of the following is the ANSI C library random number function?
    1. random()
    2. rand0()
    3. randnum()
    4. rand()


  11. The checking of input for suitability is called data ___.
    1. certification
    2. measurement
    3. validation
    4. standardization


  12. ___ programming is the art of protecting a program (by the addition of extra checks on data) from future fiddling.
    1. Protected
    2. Augmented
    3. External
    4. Defensive


  13. All of the following are advantages of the modular approach to programming except which one?
    1. It makes it easier to tinker with the program.
    2. You can fix one module and leave the rest of the program alone.
    3. You can avoid global decisions about how the program should be designed.
    4. You can often use less compiler time.


  14. What does the following statement mean? const float * ptr;
    1. The value of ptr cannot be changed.
    2. The value ptr points to cannot be changed.
    3. The address ptr points to cannot be changed.
    4. Both a and b are correct.


  15. The volatile qualifier is typically used for ___ addresses.
    1. function
    2. variable
    3. hardware
    4. pointer


  16. Which one of the following classes can only be requested rather than mandated?
    1. automatic
    2. register
    3. static
    4. external


  17. What is the keyword for the register storage class?
    1. reg
    2. auto_reg
    3. register
    4. regist


  18. Which one of the following storage classes has local scope but persistent duration?
    1. auto
    2. local
    3. static
    4. external


  19. The parts of a structure are called ____.
    1. elements
    2. members
    3. fields
    4. Either members or fields.


  20. A structure ___ is the master plan that describes how a structure is put together.
    1. framework
    2. model
    3. template
    4. form


  21. What best describes the use of the word, book, given the following code?
    struct book {
    char title[MAXT];
    char author[MAXA];
    float value;
    };
    1. A data type.
    2. A tag.
    3. A C language keyword.
    4. A switch.


  22. What is library, given the following code?
    struct book {
    char title[MAXT];
    char author[MAXA];
    float value;
    } library;
    1. a constant
    2. a pointer
    3. a template
    4. a variable


  23. To access individual members of a structure, what operator is required?
    1. :
    2. ;
    3. .
    4. ,


  24. To identify the member, title, of the fifth element of an array of structures, which of the following is correct?
    1. library[4] = title
    2. library.title[4]
    3. library[4].title[4]
    4. library[4].title;


  25. What data type is handle, given the following structure?
    struct guy{
    struct names handle;
    char favfood[LEN];
    char job[LEN];
    float income;
    };
    1. int
    2. struct names
    3. float
    4. undetermined


  26. We can state that the pointer ____ can be made to point to any structure of the ___ type, given the statement:
    struct guy * him;
    1. him, guy
    2. him, pointer
    3. guy, him
    4. guy, struct


  27. If him is a pointer to the structure, fellow[0], fellow[0].name means the same as ____.
    1. name -> him
    2. him -> fellow
    3. him -> name
    4. fellow -> him


  28. If him is a pointer to the structure, fellow[0], and income is a member of the structure, all of the following are equivalent except which one?
    1. fellow[0].income == him -> income
    2. (*him).income == him -> income
    3. fellow[0].income == (*him).income
    4. (*him).income == him -> fellow


  29. If jones[] is an array of N structures, which one of the following is used to pass the array to a function named sum()?
    1. sum( jones, N);
    2. sum(&jones, N);
    3. sum(*jones, N);
    4. sum(->jones, N);


  30. A ___ is a type that enables you to store different data types in the same memory space, but not simultaneously.
    1. set
    2. intersect
    3. array
    4. union


  31. The -> operator is known as the ___ operator.
    1. forward looking
    2. indirect membership
    3. arrow
    4. direct membership


  32. Which one of the following is a VALID typedef statement?
    1. #typedef REAL float;
    2. typedef float REAL;
    3. typedef REAL float;
    4. #typedef float REAL;


  33. Which of the following means the same as
    STRING name, sign;
    given the typedef
    typedef char * string;
    1. char * name, sign;
    2. char name, sign;
    3. char * (name, sign);
    4. char * name, * sign;


  34. What is meant by the following function prototype?
    int (*fp) (const char * ps);
    1. fp is a function that takes a pointer to char as an argument and returns an int.
    2. fp is a function that takes a pointer to char as an argument and returns a pointer to int.
    3. fp points to a function that takes a pointer to char as an argument and returns an int.
    4. fp points to a function that takes a pointer to char as an argument and returns a pointer to int.

      The answer is c. This answer is supplied because of the confusing nature of the question. Read it over and see if you understand it.