Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Programming Language
Q:
A(n) unsafe macro is one that ________.
a) evaluates its argument(s) exactly once
b) evaluates its argument(s) more than once
c) does not evaluate its argument(s)
d) None of the above.
Q:
. Which statement is false?
a) assert is a useful debugging tool for testing if a variable has a correct value
b) If NDEBUG is defined, only the next assertion is ignored.
c) The assert macro is defined in the assert.h header file.
d) One problem with using assert is that if the assertion is false, program execution is terminated; in some situations it is more appropriate to allow the program to continue executing after the program has dealt with the problem.
Q:
Which statement about the following assertion is true?
assert(count <= 7);
a) It evaluates its argument at preprocessor time.
b) It evaluates its argument at compile time.
c) It evaluates its argument at execution time.
d) It always calls function abort.
Q:
Which symbolic constant must be defined to ignore all assert statements?
(a) DEBUG
(b) NDEBUG
(c) NOASSERT
(d) UNASSERT
Q:
Which statement about predefined symbolic constants is false?
a) The predefined symbolic constants and the defined identifier cannot be used in #define or #undef directives.
b) __DATE__ is replaced by the date the source file is compiled.
c) __LINE__is used to specify the range of line numbers in the source file.
d) The identifiers for each of the predefined symbolic constants begin and end with two underscores.
Q:
Which of the following is not a predefined symbolic constant?
(a) __ERROR__
(b) __FILE__
(c) __TIME__
(d) __LINE__
Q:
The preprocessor directive
#line 200
a) numbers the first 200 lines of a source-code program from 1 to 200.
b) numbers the first 200 lines of a source-code program from 0 to 199.
c) starts line numbering from 200 beginning with the next source-code line
d) numbers the next line 200 and has no effect on other lines.
Q:
The statement #line 250
(a) causes the compiler to ignore everything after line 250.
(b) causes the compiler to renumber the lines from 250 beginning with the next source code line.
(c) causes the compiler to renumber the lines from 250 beginning with this statement line.
(d) causes line number 250 to be replaced by the text following the statement.
Q:
Operator ##
a) concatenates two tokens in a macro definition.
b) is a relational operator.
c) is the conditional-compilation operator.
d) is the symbolic-constant operator.
Q:
Given the preprocessor directive
#define HAPPY(x) printf ("Happy, " #x "
");
How would you invoke this macro to generate a statement that would print
Happy BIRTHDAY (followed by a newline)
at execution time?
a) Happy(Birthday)
b) Happy(BIRTHDAY)
c) HAPPY(Birthday)
d) HAPPY(BIRTHDAY)
Q:
The # preprocessor operator causes a replacement text token to be converted to
a) an integer
b) a string
c) a string surrounded by quotes
d) an integer surrounded by quotes
Q:
The # operator causes __________ to be converted to a __________.
(a) any preprocessor argument, user-defined type.
(b) a text token, string surrounded by quotes.
(c) a string, concatenated string.
(d) any float or int, string.
Q:
To customize preprocessing to the unique needs of a particular installation, you would most likely use the __________ directive.
a) #unique
b) #pragmatic
c) #pragma
d) #customize
Q:
A pragma not recognized by the implementation
a) causes the compilation to terminate.
b) prints an error message and causes the compilation to terminate.
c) prints an error message and allows the complation to continue.
d) is ignored.
Q:
The preprocessor directive
#pragmatokens
a) prints only the tokens specified in the message.
b) prints the word pragma followed by the tokens specified in the message.
c) causes an implementation-defined action.
d) prints an implementation-defined message including the tokens specified in the directive.
Q:
The preprocessor directive
#error 7 " Out of range error "
contains __________ tokens.
a) 8
b) 7
c) 9
d) 6
Q:
The #error directive
#errortokens
a) prints only the tokens specified in the message.
b) prints the word error followed by the tokens specified in the message.
c) prints only an implementation-defined message.
d) prints an implementation-defined message including the tokens specified in the directive.
Q:
Which line has the most tokens?
(a) I like C.
(b) I like C++ better.
(c) I like C + +.
(d) I prefer Java.
Q:
The __________ directive prints out a message.
(a) #error
(b) #pragma
(c) all of the above
(d) none of the above.
Q:
Which statement about conditional compilation is false?
a) Conditional compilation is commonly used as a debugging aid.
b) For debugging purposes, printf statements can be enclosed in conditional preprocessor directives so that the statements are compiled only while the debugging process is not completed.
c) A correct example of using a conditionally compiled printf statement only while a program is being debugged is
#ifdef DEBUG
printf("Variable x = %d
", x) ;
#endif
d) A single, conditionally compiled printf statement may be inserted in a program anywhere the C compiler expects a single statement.
Q:
Which statement about "commenting out" code is false?
a) During program development, programmers often find it helpful to "comment out" portions of code to prevent it from being compiled.
b) Code may not always be "commented out" correctly simply by enclosing that code in the C comment delimiters /* and */.
c) The following preprocessor code effectively comments out code
#if 0
code prevented from compiling
#endif
d) The following preprocessor code effectively comments out code
#if 1
code prevented from compiling
#endif
Q:
A shorthand for #if !defined is
a) #ifndef
b) #ifnotdef
c) #ifnotdefined
d) #ifndf
Q:
Every #if construct
a) must end with #end.
b) always affects code throughout the entire body of the program.
c) is used for debugging.
d) must end with #endif.
Q:
What does the following preprocessor code do?
#if !defined(NULL)
#define NULL 0
#endif
a) The code is incorrect, so it generates an error at preprocessor time.
b) The code ensures that NULL is always 0.
c) The code defines NULL to be 0 only if NULL is undefined.
d) The code ensures that NULL is defined throughout the entire program file.
Q:
Which statement is false?
a) Cast expressions cannot be evaluated in preprocessor directives.
b) Arithmetic expressions cannot be evaluated in preprocessor directives.
c) sizeof expressions cannot be evaluated in preprocessor directives.
d) Enumeration constants cannot be evaluated in preprocessor directives.
Q:
Conditional compilation cannot be used to
(a) perform loops.
(b) ignore large blocks of code.
(c) debug programs.
(d) selectively define symbolic constants.
Q:
Which of the following is not a valid directive?
(a) #endif
(b) #ifdef
(c) #for
(d) #elif
Q:
Large portions of code can be prevented from compiling by
(a) #if 0
code prevented from compiling
#endif
(b) #nodefine
code prevented from compiling
#endif
(c) #if 1
code prevented from compiling
#endif
(d) #ifndef 0
code prevented from compiling
#endif
Q:
Which statement is correct?
a) Expressions with side effects (i.e., variable values are modified) should not be passed to a macro because macro arguments may be evaluated more than once.
b) Expressions with side effects (i.e., variable values are modified) should not be passed to a macro because macro arguments are evaluated only once.
c) Expressions with side effects (i.e., variable values are modified) should be passed to a macro because macro arguments may be evaluated more than once.
d) Expressions with side effects (i.e., variable values are modified) should be passed to a macro because macro arguments are evaluated only once.
Q:
A macro commonly defined in the stdio.h header file is
a) #define getchar() getchar(stdin)
b) #define getchar() getc(stdin)
c) #define getc() getchar (stdin)
d) #define getc() getc(stdin)
Q:
Which statement about symbolic constants and/or macros is true?
a) The effects of symbolic constants and macros, once defined, cannot be modified.
b) Preprocessor directive #removedef undefines a symbolic constant or macro.
c) The scope of a symbolic constant or macro is normally from its point of definition to the end of the file, but this can be modified with a preprocessor directive.
d) A name can always be redefined with #define.
Q:
Symbolic constants and macros can be discarded by using the __________ preprocessor directive.
a) #undefine
b) #discard
c) #dscrd
d) #undef
Q:
Macros
a) can help avoid the overhead of a function call.
b) execute before a program is compiled.
c) never add subtle bugs to programs.
d) cannot be used to replace a function call with inline code.
Q:
The parentheses around the two rightmost occurrences of x in the following preprocessor directive:
#define CIRCLE_AREA(x) ((PI) * (x) * (x))
a) are always required.
b) are included to improve program readabiliy.
c) are included to eliminate bugs when an expression is substituted for x.
d) should be curly braces { }.
Q:
Which statement about macros is true?
a) Macros always make programs run faster.
b) Macros cannot have arguments.
c) Macros cause text replacement at execution time.
d) Macro arguments should be enclosed in parentheses in the replacement text.
Q:
Macros are defined
a) in an #include preprocessor directive
b) in a #define preprocessor directive
c) in a #macro preprocessor directive
d) using keyword #MACRO in a C function.
Q:
Macros have the disadvantage, when compared to functions, of
(a) having the overhead of a function call.
(b) increasing program size (if the macros are called from many places in the program).
(c) having to fit the macro definition on a single line.
(d) taking only one argument.
Q:
Which of the following is false? Macros
(a) must be defined with arguments.
(b) are replaced by their replacement text during execution time.
(c) cannot be redefined once defined.
(d) have no data type checking.
Q:
The #undef preprocessor directive
(a) can only be used once per macro name.
(b) can only be used on symbolic constants.
(c) allows macros to be redefined with #define later in the program.
(d) must be called for all symbolic constants before the end of the file.
Q:
If the macro
#define RECTANGLE_AREA(x, y) ((x) * (y))
has been defined. Then the line
rectArea = RECTANGLE_AREA(a + 4, b + 7);
will be expanded to
(a) rectArea = 11;
(b) rectArea = (a + 4 * b + 7);
(c) rectArea = ((a + 4) * (b + 7));
(d) RECTANGLE_AREA(a + 4 , b + 7);
Q:
What is a problem with the preprocessor statement:
#define PI 3.14159;
a) It will make a program run slower.
b) #define should be #def
c) PI should be spelled with lowercase letters.
d) The semicolon is part of the substitution text, so 3.14159; will be substituted whereever PI is used and this could lead to syntax errors.
Q:
Which statement about symbolic constants is true?
a) They make programs run faster.
b) They always make programs clearer.
c) They make it more difficult to modify programs.
d) Using meaningful names for symbolic constants helps make programs more self-documenting.
Q:
Which statement is false?
a) Symbolic constants are constants represented as symbols.
b) Macros are operations defined as symbols.
c) All text replacement with symbolic constants and macros occurs before the program is compiled.
d) Symbolic constants may be redefined with new values.
Q:
Which of the following statements is correct?
(a) #define X = 3
(b) #define X 3, Y 4
(c) #define X 3
(d) #define X:3
Q:
. const variables are preferred to symbolic constants (from #define) because
(a) constvariables take up less memory.
(b) symbolic constants can be changed.
(c) const variable names are visible to the compiler
(d) const variables do not have to be of a specific data type.
Q:
Which statement about the #include preprocessor directive is false?
a) It is used with programs consisting of several source files that are to be compiled together.
b) A header file containing definitions common to separate program files is often created and included in a program with #include.
c) #include header files often contain structure and union definitions, enumerations and function prototypes.
d) It includes standard library header files such as standardio.h.
Q:
Which statement about the #include directive is false?
a) The difference between the various forms of the #include directive is the location the preprocessor searches for the file to be included.
b) If the file name is enclosed in quotes, the preprocessor searches in the same directory as the file being compiled for the file to be included.
c) If the file name is enclosed in angle brackets, the preprocessor searches in the same directory as the file being compiled for the file to be included.
d) The preprocessor searches for standard library header files in an implementation-dependent manner.
Q:
Which is a correct form of the #include directive
a) #include "filename"
b) #include /filename/
c) #include #filename
d) #include <filename>
Q:
The #include directive
a) must begin in column 1
b) includes a file in the program at execution time
c) includes a file in the program before compilation
d) appends a file to the end of the program
Q:
Which include statement is usually appropriate for user-defined files?
(a) include <filename>
(b) #include "filename"
(c) Both (a) and (b) are appropriate.
(d) Neither (a) nor (b) is appropriate.
Q:
The #includepreprocessor directive causes a(n) ____________ to be included in place of the directive.
(a) copy of a file
(b) # character
(c) pointer to a file
(d) bitfield
Q:
Which statement about the preprocessor is false?
a) it can perform conditional compilation of program code
b) it can perform conditional execution of preprocessor directives
c) all preprocessor directives begin with #
d) all preprocessor directives must end in a semicolon.
Q:
Which is not a capability of the preprocessor?
a) inclusion of other files in the file being compiled
b) definition of functions
c) definition of symbolic constants
d) definition of macros
Q:
Preprocessor directives
(a) begin with include
(b) are C statements.
(c) are ignored if whitespace characters before them on the same line.
(d) do not end in a semicolon.
Q:
Preprocessing occurs
(a) before a program is compiled.
(b) during compilation.
(c) after compilation but before execution.
(d) immediately before execution.
Q:
Which of the following statements is false?
(a) Pointers should not be left uninitialized.
(b) When you use free to deallocate dynamically allocated memory, the pointer passed to free is set to NULL.
(c) Undefined behavior occurs when you attempt to use free to deallocate dynamic memory that was already deallocated
(d)Function malloc returns NULL if it's unable to allocate the requested memory.
Q:
Which statement about the level-order traversal of a binary tree is false?
a) It visits the nodes of a tree row by row.
b) The search begins at the root node.
c) The search begins at the row of the leftmost leaf node.
d) On each level of the tree, the nodes are visited left to right.
Q:
Which of the following statements about binary search trees is false?
a) The binary search tree facilitates duplicate elimination.
b) In a tightly packed binary search tree, each level contains about half as many elements as the previous level. (The previous level is the level closer to the root node.)
c) When searching a tightly packed billion-element search tree, only about 30 elements (or fewer) are required to locate most elements.
d) When searching a tightly packed million-element search tree, only about 20 elements (or fewer) are required to locate most elements.
Q:
Which type of binary search tree traversal processes the node values in ascending order?
a) in-order traversal
b) pre-order traversal
c) post-order traversal
d) duplicate elimination traversal
Q:
The steps for an in-order traversal of a binary search tree include each of the following except _________.
a) Traverse the left subtree in-order.
b) Process the value in the root node.
c) Skip over duplicate values.
d) Traverse the right subtree in-order,
Q:
A node can only be inserted __________ in a binary search tree.
a) as the root node
b) as a leaf node
c) as a parent node
d) as an ancestor node
Q:
Which of the following statements about binary search trees with no duplicate values is false?
a) The values in any left subtree are less than the values in its parent node.
b) The values in any right subtree are less than the values in its parent node.
c) The shape of the tree that corresponds to a particular set of data can vary based on the order in which the values are inserted into the tree.
d) It is possible that a binary tree could contain all its values along one straight path through the tree.
Q:
Which statement is not true for binary trees.
a) The left child in the root node is the first node in the left subtree.
b) The children of a node are called siblings.
c) A node with no children is called an orphan.
d) The root node is the first node in the tree.
Q:
Which statement about trees is false?
a) A tree is a non-linear, two-dimensional data structure.
b) Tree nodes contain two or more links.
c) Binary tree nodes contain two or fewer links.
d) Binary tree nodes contain exactly two links.
Q:
If you have a 1000-element balanced binary search tree, what is the maximum number of comparisons that may be needed to find an element in the tree?
(a) 500
(b) 10
(c) 20
(d) 8
Q:
Suppose you have a list of names sorted in alphabetical order, already stored in one of the data types below. The easiest way to print the names in reverse alphabetical order would be to use a
(a) binary search tree
(b) stack
(c) queue
(d) circular, singly linked list
Q:
Add the following nodes to a binary search tree in the order they appear.
6 34 17 19 16 10 23 3
What is the output of a postorder traversal of this tree?
(a) 3 10 16 23 19 17 34 6
(b) 3 6 17 16 10 19 23
(c) 6 3 34 17 16 10 19 23
(d) 10 16 23 19 17 34 3 6
Q:
Select the incorrect statement. Binary trees (regardless of the order in which the values are inserted into the tree)
(a) always have multiple links per node.
(b) can be sorted efficiently.
(c) always have the same shape for a particular set of data.
(d) are nonlinear data structures.
Q:
Which of the following is not true of queues?
a) Network packets wait in queues for service at routers .
b) The entry at the front (or head) of the queue is the next to be removed.
c) Queues are used to support print spooling.
d) Queues are used to support high-speed sorting algorithms.
Q:
Queues are linear data structures with the property that queue nodes are inserted only at the tail of the queue and removed only from the head of the queue. For this reason, queues are referred to as __________ data structures.
a) first-in, first-out
b) first-in, last-out
c) last-in, first-out
d) first-come, first-served
Q:
A linked list has the functions insertAtFront, removeFromFront, insertAtBack, and removeFromBack, which perform operations on nodes exactly as their names describe. Which two functions would most
naturally model the operation of a queue?
(a) insertAtBackand removeFromBack.
(b) insertAtBackand removeFromFront.
(c) insertAtFrontand removeFromFront.
(d) insertAtFrontand removeFromBack.
Q:
A queue receives the following commands (in pseudo-code):
enqueue 4, 6, 8, 3, 1
dequeue three elements
enqueue 3, 1, 5, 6
dequeue two elements
What number is at the front of the queue?
(a) 3
(b) 4
(c) 5
(d) 6
Q:
Which is not a popular application of stacks?
a) enabling called functions to return to their callers
b) supporting recursive function calls
c) containing the space created for automatic variables
d) maintaining waiting lines
Q:
Which of the following statements is false?
a) The primary functions used to manipulate a stack are push and pop.
b) Function pop removes a node from the bottom of the stack.
c) Function push creates a new node and places it on top of the stack.
d) A stack can be implemented as a constrained version of a linked list by allowing insertions and deletions only at one end of the linked list.
Q:
The link member in the last node of a stack is typically set to __________ indicate the bottom of the stack.
a) void
b) void *
c) NULL
d) empty
Q:
New nodes can be added to a stack and removed from the stack only at its top. For this reason a stack is referred to as a __________ data structure.
a) first-in, first-out
b) linear
c) last-in, first-out
d) dynamic
Q:
A stack is initially empty, then the following commands are performed.
push 5
push 7
pop
push 10
push 5
pop
Which of the following is the correct stack (assume the top of the stack is on the left).
(a) 5 10 7 5
(b) 5 10
(c) 7 5
(d) 10 5
Q:
Which of the following statements about stacks is incorrect?
(a) stacks can be implemented using linked lists.
(b) stacks are first in, first-out (FIFO) data structures.
(c) new nodes can only be added to the top of the stack.
(d) the last node (the bottom) of a stack has a null (zero) link.
Q:
Passing a pointer to a pointer is called __________.
a) double direction
b) pointer passing
c) double indirection
d) indirection
Q:
Functions such as isEmpty and isFull that test a condition and return a value that can be interpreted as true or false, are called __________ functions.
a) imperative
b) declarative
c) predicate
d) conditional