|<< Calculation of Drug Dosages A Work Text 9th Edition by Sheila J. Ogden Test Bank||Community & Public Health Nursing Promoting the Public Health 8th ed by Allender , Judith Test Bank >>|
2.2 A Simple C Program: Printing a Line of Text
2.1 Which of the following must every C program have?
2.2 Every statement in C must end with a
(a) period (.)
(b) semicolon (;)
(c) colon (:)
(d) backslash (/)
2.3 Which of the following is not a valid escape sequence?
2.4 Which statement about comments is false?
2.5 Lines beginning with a # are processed
2.6 Which of the following statements about the inclusion of
2.7 In the line
the parentheses indicate that main is a program building block called a
2.8 The pair of braces that delineate the body of main and the portion of the program between these braces is called a __________.
2.9 Which of the following is not a synonym for a C string?
2.10 The following line is most properly an example of a __________.
puts( Welcome to C! );
2.11 In a printf, a backslash is printed by enclosing in quotes
2.12 A linked program is often called a(n) __________.
2.13 The escape sequence for horizontal tab is __________.
2.3 Another Simple C Program: Adding Two Integers
2.14 Which of the following is not a valid integer value?
2.15 Which of the following is an invalid identifier (variable name)?
2.16 Which statement prints hi on the screen?
(b) put hi;
(c) puts hi;
(d) none of the above
2.17 The __________ sign is also known as the __________ operator.
(a) +, assignment
(b) =, assignment
(c) *, stream manipulator
(d) &, stream insertion
2.18 A(n) __________ is a location in the computers memory where a value can be stored for use by a program.
2.19 Which statement is false.
2.20 Which of these is not a valid identifier?
2.21 Which of the following statements is false?
2.22 Which of the following multiple word variable names does not conform to the good programming practices in the text?
2.23 The address operator is
2.24 Which statement is false?
sum = integer1 + integer2;
both = and + are binary operators.
2.25 Which of the following is false?
2.4 Memory Concepts
2.26 Variable names actually correspond to __________.
(a) locations in the computers memory
(d) data types
2.27 When a number gets assigned to a variable that already has a value __________.
(a) the new number overwrites the previous value at that memory location
(b) the new number gets assigned to a neighboring memory location
(c) the computer issues an error
(d) the new value is destroyed and the old value remains
2.28 Every variable has all the attributes below, except
2.29 Which of the following is false?
2.5 Arithmetic in C
2.30 Which operation will find the remainder when 15 is divided by 6?
(a) 15 / 6
(b) 15 % 6
(c) 15 ^ 6
(d) 15 * 6
2.31 Evaluate the expression
3 * 4 % 6 + 4 * 5
2.32 Which statement is false?
2.33 Which statement about C arithmetic is false?
2.34 a * ( b + c ) may also be written in C as
2.35 Which statement about precedence is false?
2.36 Which expression is true?
2.6 Decision Making: Equality and Relational Operators
2.37 Cs if statement executes the statement inside its body if a specified __________ is __________.
(a) condition, true
(b) condition, false
(c) equality operator, true
(d) relational operator, true
2.38 Which of the following is an equality operator?
2.39 Which statement is false?
2.40 Which statement is false?
2.41 Which statement is false?
2.42 Which of the following is not a keyword?
2.43 Which statement is false?
2.44 The order in which statements are __________ is called flow of control.
2.7 Secure C Programming
2.45 Which of the following statements is true in secure C programming?
(a) You should avoid using printf to display a single string argument.
(b) You should always use printf to display a single string argument.
(c) You should always use puts to display a single string argument.
(d) None of the above.
2.46 Which of the following statements should be used in secure C programming to display the string Welcome not followed by a newline character?
(a) printf( Welcome );
(b) puts( Welcome );
(c) printf( %s, Welcome );
(d) None of the above.
12.1 __________ are collections of data items lined up in a rowinsertions and deletions are made anywhere in a __________.
12.2 __________ are important in compilers and operating systemsinsertions and deletions are made only at one end of a __________its top.
12.3 __________ represent waiting lines; insertions are made at the back (also called the tail) and deletions are made from the front (also called the head) of a __________.
12.4 __________ facilitate high-speed searching and sorting of data, efficient elimination of duplicate items and compiling expressions into machine language.
12.2 Self-Referential Structures
12.5 A self-referential structure contains a ________ member that points to ________.
(a) integer, a structure of the same structure type
(b) pointer, an integer
(c) integer, an integer
(d) pointer, a structure of the same structure type
12.6 A(n) __________ pointer normally indicates the end of a data structure.
12.3 Dynamic Memory Allocation
12.7 A __________ occurs when dynamically allocated memory is not returned when its no longer needed.
(a) memory leak
(b) self-referential error
(c) allocation error
(d) sizeof error
12.8 __________ memory allocation is the ability for a program to obtain more memory space at execution time and to release space no longer needed.
12.9 Function malloc takes as an argument the number of bytes to be allocated, and returns a pointer of type __________ to the allocated memory.
12.10 If no memory is available malloc returns a(n) __________ pointer.
12.11 Which of the following statements is true?
12.12 Which is correct?
12.13 Not returning dynamically allocated memory when it is no longer needed can cause a system to run out of memory prematurely. This is called a(n) __________.
12.14 When memory allocated with malloc is no longer needed, return that memory to the system immediately with __________.
12.15 Which of these is not a common programming error?
12.4 Linked Lists
12.18 __________ is not an advantage of linked lists when compared to arrays.
(a) Dynamic memory allocation
(b) Efficient insertion and deletion
(c) Direct access to any list element
(d) Efficient use of memory
12.19 For a non-empty linked list, select the code that should appear in a function that adds a node to the end of the list. newPtr is a pointer to the new node to be added, and lastPtr is a pointer to the current last node. Each node contains a pointer nextPtr, a link to a node.
lastPtr->nextPtr = newPtr;
lastPtr = newPtr;
lastPtr = newPtr;
lastPtr->nextPtr = newPtr;
newPtr->nextPtr = lastPtr;
lastPtr = newPtr;
lastPtr = newPtr;
newPtr->nextPtr = lastPtr;
12.20 How many pointers are contained in a circular, doubly linked list with five nodes?
12.21 A linked list is a __________ collection of self-referential structures, called nodes, connected by pointer links.
12.22 Which of the following is a non-linear data structure?
12.23 Which of the following is false?
12.24 Which of the following is false?
12.25 Which statement is false?
12.26 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.
12.27 Passing a pointer to a pointer is called __________.
12.28 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.
12.29 A stack is initially empty, then the following commands are performed.
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
12.30 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.
12.31 The link member in the last node of a stack is typically set to __________ indicate the bottom of the stack.
12.32 Which of the following statements is false?
12.33 Which is not a popular application of stacks?
12.34 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?
12.35 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) insertAtBack and removeFromBack.
(b) insertAtBack and removeFromFront.
(c) insertAtFront and removeFromFront.
(d) insertAtFront and removeFromBack.
12.36 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.
12.37 Which of the following is not true of queues?
12.38 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.
12.39 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
12.40 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
(d) circular, singly linked list
12.41 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?
12.42 Which statement about trees is false?
12.43 Which statement is not true for binary trees.
12.44 Which of the following statements about binary search trees with no duplicate values is false?
12.45 A node can only be inserted __________ in a binary search tree.
12.46 The steps for an in-order traversal of a binary search tree include each of the following except _________.
12.47 Which type of binary search tree traversal processes the node values in ascending order?
12.48 Which of the following statements about binary search trees is false?
12.49 Which statement about the level-order traversal of a binary tree is false?
12.8 Secure C Programming
12.50 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 its unable to allocate the requested memory.
Chapter 22: Exception Handling: A Deeper Look
Section 22.1 Introduction
22.1 Q1: Exception handling may allow a program to:
ANS d. All of the above.
Section 22.2 Example: Handling an Attempt to Divide by Zero
22.2 Q1: The correct order in which an exception is detected and handled is:
ANS d. try, throw, catch
22.2 Q2: Once an exception is thrown, when can control return to the throw point?
ANS a. Never.
22.2 Q3: The try block cannot:
ANS b. Enclose its own catch blocks.
22.2 Q4: catch blocks are not required to contain:
ANS d. A parameter name.
22.2 Q5: An exception:
ANS b. Terminates the block where the exception occurred.
Section 22.3 Rethrowing an Exception
22.3 Q1: To rethrow an exception, the exception handler must:
ANS a. Use the throw; statement.
22.3 Q2: Select the false statement. A rethrown exception:
ANS d. Must have been fully processed at the time it was rethrown.
Section 22.4 Stack Unwinding
22.4 Q1: The purpose of stack unwinding is to:
ANS: a. Attempt to catch exceptions that are not caught in their scope.
Section 22.5 When to Use Exception Handling
22.5 Q1: Exception handling should not be used:
ANS a. As an alternative for program control.
Section 22.6 Constructors, Destructors and Exception Handling
22.6 Q1: Select the false statement. If an exception is thrown from a constructor:
ANS: b. For an array, destructors for all array elements are called, even if those array elements have not yet been constructed.
Section 22.7 Exceptions and Inheritance
22.7 Q1: An advantage of using inheritance with exceptions is:
ANS: a. The ability to catch related errors easily.
Section 22.8 Processing new Failures
22.8 Q1: Select the false statement. Depending on the compiler:
ANS: d. A failed new operation can automatically be caught at compile time.
22.8 Q2: Select the false statement. The new operator:
ANS: d. Throws a bad_alloc exception regardless of what function is registered with set_new_handler.
Section 22.9 Class unique_ptr and Dynamic Memory Allocation
22.9 Q1: If dynamic memory has been allocated for an object and an exception occurs, then:
ANS: b. A memory leak could result.
22.9 Q2: Which statement about class unique_ptr (of the new C++ standard) and dynamic memory allocation is false?
ANS: b. When a unique_ptr object destructor is called (for example, when a unique_ptr object goes out of scope), it performs a destroy operation on its pointer data member. [The operation is delete.]
Section 22.10 Standard Library Exception Hierarchy
22.10 Q1: Select the false statement regarding exceptions.
ANS: b. All exception classes are accessible via
22.10 Q2: Which class indicates that an error occurred in which an arithmetic result was larger than the largest number that can be stored in the computer?
ANS: d. overflow_error.
Once the order is placed, the order will be delivered to your email less than 24 hours, mostly within 4 hours.
If you have questions, you can contact us here