CS 216

Review for Third Quiz

  1. Preprocessor directives run until they reach the first ___ following the # sign.
    1. ;
    2. newline
    3. EOF
    4. end-of-string marker


  2. The general form of #define is which one of the following?
    1. #define body macro;
    2. #define body macro
    3. #define macro body;
    4. #define macro body


  3. All of the following are reasons for using symbolic constants in preprocessor directives except which one?
    1. Allows for preprocessor calculations
    2. Improves program portability
    3. Simplifies program modifications
    4. Adds mnemonic value


  4. How many tokens are there in the following definition?
    #define SIX 2 * 3
    1. 1
    2. 3
    3. 4
    4. 5


  5. With ANSI C, a preprocessor directive can be redefined if _____.
    1. The new definition is greater than the old.
    2. The new definition is less than the old.
    3. The new definition is the same as the old.
    4. A redefinition is not allowed with ANSI C.


  6. A macro call, unlike a function call, passes the argument ___ to the program ___ compilation.
    1. value, before
    2. token, before
    3. value, after
    4. token, after


  7. Which one of the following operators should not be used with macros?
    1. *
    2. --
    3. ++
    4. Both b and c.


  8. Which one of the following statements about macros is false?
    1. There are no spaces in macro names.
    2. Macros always improve program execution time.
    3. Parentheses help to clarify the arguments in the body of a macro.
    4. Capital letters can be used for macro names.


  9. Which one of the following #include directives tells the preprocessor to look for the header file , mystuff, in the current directory (not the system directory)?
    1. #include "mystuff.h"
    2. #include <mystuff.h>
    3. #include "mystuff.c"
    4. #include <mystuff.c>


  10. Standard header files store all of the following except?
    1. macro functions
    2. function declarations
    3. structure template definitions
    4. manifest constraints


  11. Which preprocessor directive cancels an earlier #define directive?
    1. #undefine
    2. #undif
    3. #undef
    4. #undeff


  12. Which one of the following directives is the negative of #ifdef?
    1. #nifdef
    2. #ifdefn
    3. #ifnodef
    4. #ifndef


  13. All of the following are conditional compilation preprocessor directives, except?
    1. #ifelse
    2. #endif
    3. #else
    4. #ifdef


  14. Which one of the following is the correct way of assigning values to an enumerated type?
    1. enum spectrum [red, orange, yellow, blue];
    2. enum spectrum {red, orange, yellow, blue};
    3. enum spectrum [red, orange, yellow, blue]
    4. enum spectrum {red, orange, yellow, blue}


  15. Technically, enum constants are type ___ constants.
    1. string
    2. char
    3. int
    4. float


  16. By default, what value is assigned to skippy, given the statement:
    enum kids {nippy, slats, skippy, nina, liz };
    1. 2
    2. 3
    3. 6
    4. Cannot tell without an assignment.


  17. Which value is assigned to skippy given the statement:
    enum kids {nippy, slats = 10, skippy, nina, liz };
    1. 2
    2. 3
    3. 6
    4. 11


  18. Which one of the following is the square root function, as found in the math.h header file?
    1. square()
    2. sqroot()
    3. squrt()
    4. sqrt()


  19. Which one of the following is the general utilities library?
    1. stdio.h
    2. math.h
    3. stdlib.h
    4. ctype.h


  20. The ___ function registers the functions to be called when a program exits (from the use of an exit function).
    1. exit(5)
    2. apexit()
    3. aexit()
    4. atexit()


  21. How many arguments are required by the malloc function?
    1. 0
    2. 1
    3. 2
    4. 3


  22. By using malloc(), a program can decide what memory is needed and create it when the program is ___.
    1. written
    2. compiled
    3. preprocessed
    4. run


  23. Which of the following functions releases memory allocated by malloc()?
    1. free()
    2. release()
    3. renew()
    4. letgo()


  24. How many arguments are required by the calloc function?
    1. 0
    2. 1
    3. 2
    4. 3


  25. Which of the following functions releases memory allocated by calloc()?
    1. free()
    2. release()
    3. renew()
    4. letgo()


  26. With malloc() and calloc(), memory persistence is controlled by the _____.
    1. stack
    2. compiler
    3. malloc() and calloc() functions
    4. programmer