Walter McHenry C Programming Final-Exam

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

3.6 The if...else Selection Statement 3.35 The conditional operator (?:) ________. (a) is the only ternary operator in C (b) is a unary operator (c) associates from left to right (d) accepts two operands

(a)

3.10 Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 3: Nested Control Structures 3.52 Having a loop within a loop is known as (a) recursion (b) doubling up (c) nesting (d) a redundancy

(c)

5.5. When a called function completes its task, it normally a) terminates program execution normally b) aborts program execution c) logs its results d) returns to the calling function

(d)

5.50. Which is not an attribute of a variable? a) storage class b) storage duration c) scope d) external class

(d)

5.51. An identifier's __________ is where the identifier can be referenced in a program. a) locality b) vicinity c) neighborhood d) scope

(d)

1.10 Java 1.24 Java was developed by ___________. (a) Sun Microsystems (b) Bell Labs (c) IBM (d) ANSI/ISO

(a)

1.23 C++ was developed by ________. (a) Bjarne Stroustrup (b) Ada Lovelace (c) Blaise Pascal (d) Ken Thompson

(a)

3.12 Increment and Decrement Operators 3.56 Which of the following will not increment variable c by one? (a) c + 1; (b) c++; (c) ++c; (d) c += 1;

(a)

3.19. The __________ selection statement performs an action if a condition is true and skips that action if the condition is false. a) if b) when c) if ...else d) switch

(a)

3.22. The __________ is called a single selection structure. a) if b) when c) if ...else d) switch

(a)

3.26. Which statement is true? a) Each of C's control structures is characterized as being single-entry, single-exit. b) Each of C's control structures is characterized as being single-entry, multiple-exit. c) Each of C's control structures is characterized as being multiple-entry, single-exit. d) Each of C's control structures is characterized as being multiple-entry, multiple-exit.

(a)

3.48 In indefinite repetition, an input value (a) should always be evaluated before being processed (b) should always be processed directly after it is entered (c) should never be modified (d) can be entered, processed, and evaluated in any order

(a)

3.8 Formulating Algorithms Case Study 1: Counter-Controlled Repetition 3.44 An uninitialized variable contains ________. (a) the value last stored in the memory location reserved for that variable (b) no value (c) a value of zero (d) a randomly assigned value

(a)

4.1 Introduction 4.1. Which is not a repetition structure? a) continue b) for c) while d) do ... while

(a)

4.11 Confusing Equality (==) and Assignment (=) Operators 4.54 Variables are also known as (a) lvalues, but can be used as rvalues (b) lvalues, and can not be used as rvalues (c) rvalues, but can be used as lvalues (d) constant variables

(a)

4.15. Which statement automatically handles all the details of counter-controlled repetition. a) for b) while c) do ...while d) continue

(a)

4.2 Repetition Essentials 4.3 ________ repetition is sometimes called definite repetition. (a) counter-controlled (b) sentinel-controlled (c) variable-controlled (d) none of these

(a)

4.20. Which statement is false? a) Comma operators evaluate lists of expressions from right to left. b) The value of a comma-separated list of expressions is the value of the rightmost expression in the list. c) The type of a comma-separated list of expressions is the type of the rightmost expression in the list. d) The comma operator is often used to specify multiple initializations in one particular type of repetition structure.

(a)

4.34. Which statement is generally false? a) Statements preceding a for and statements in the body of a for should typically be merged into the for header. b) Limit the size of control structure headers to a single line, if possible. c) Initialization of a for loop control variable can occur before the for loop executes and not in the loop itself. d) The increment portion of a for header can be a decrement.

(a)

4.55 Consider the following code, assuming that x is an integer variable with an initial value of 12: if( x = 6 ) printf("%i", x); What is the output? (a) 6 (b) 12 (c) nothing (d) a syntax error is produced

(a)

5.13 Scope Rules 5.53 Labels are the only identifiers with (a) function scope (b) file scope (c) block scope (d) function-prototype scope

(a)

5.19 Using the following function definition, the return value type is represented by A B( C ) { D } (a) A (b) B (c) C (d) D

(a)

5.26. The type of a parameter whose type is omitted in a function defeinition is __________. a) int b) double c) long d) float

(a)

5.31. Which statement is true? a) Programs should be written as collections of small functions. b) A function must be no longer than one page. c) The best engineered functions have many parameters and perform many distinct tasks. d) Every function must include an explicit return statement.

(a)

5.33 A function prototype can always be omitted when: (a) a function is defined before it is first invoked (b) a function is invoked before it is first defined (c) a function takes no arguments (d) a function does not return a value

(a)

5.4. Which one item is most different from the other three? a) worker function b) caller c) calling function d) boss function

(a)

5.44. Which statement is false? a) Function rand generates an integer between 0 and MAX. b) The range of values produced directly by rand is often different than what is needed in a specific application. c) The number 6 in the expression rand % 6 is called a scaling factor. d) The rand function prototype is in <stdlib.h>.

(a)

5.47 Which of the following is not true of static local variables? (a) they are accessible outside of the function in which they are defined (b) they retain their values when the function is exited (c) they are initialized to zero if not explicitly initialized by the programmer (d) they can be pointers

(a)

5.49. Which is not a storage class a) automatic b) register c) extern d) static

(a)

5.5 Function Definitions 5.17 The function prototype double mySqrt( int x ); (a) defines a function called mySqrt which takes an integer as an argument and returns a double (b) defines a function called double which calculates square roots (c) defines a function called mySqrt which takes an argument of type x and returns a double (d) defines a function called mySqrt which takes a double as an argument and returns an integer

(a)

5.55. Which statement is false? a) When we define a local variable in a block it can be referenced only in that block or in blocks in which that block is nested. b) Labels are the only identifiers with function scope. c) Labels can be used anywhere in the function in which they appear, but can not be referenced outside the function body. d) Labels are used in switch statements and in goto statements.

(a)

5.6 Function Prototypes 5.32 A function prototype does not have to (a) include parameter names (b) terminate with a semicolon (c) agree with the function definition (d) match with all calls to the function

(a)

6.14 Referencing elements outside the array bounds (a) can result in changes to the value of an unrelated variable (b) is impossible because C checks to make sure it does not happen (c) is a syntax error (d) enlarges the size of the array

(a)

6.23. Which statement is true? a) Assigning a value to a symbolic constant in an executable statement is a syntax error. b) A symbolic constant is a variable. c) Space is reserved for both symbolic constants and variables that hold values at execution time. d) Only uppercase letters can be used for symbolic constant names.

(a)

6.24. Which statement is true regarding the statement ++frequency[ responses[ answer ] ]; a) This statement increases the appropriate frequency counter depending on the value of responses[ answer ]. b) This statement increases the appropriate answer counter depending on the value of frequency[ responses ]. c) This statement increases the appropriate responses counter depending on the value of frequency[ answer ]. d) This statement produces a syntax error because subscripts cannot be nested.

(a)

6.31 Which of the following is false about a function being passed an array? (a) it knows the size of the array it was passed (b) it is passed the address of the first element in the array (c) it is able to modify the values stored in the array (d) all of the above are true

(a)

6.33. To pass an array to a function, specify a) the name of the array without any brackets. b) the name of the array preceded by an empty pair of brackets. c) the name of the array followed by a pair of brackets including the size of the array. d) the name of the array followed by a pair of brackets including a number one less than the size of the array.

(a)

6.4 Array Examples 6.12 Which of the following is not a correct way to initialize an array? (a) int n[ 5 ] = { 0, 7, 0, 3, 8, 2 }; (b) int n[] = { 0, 7, 0, 3, 8, 2 }; (c) int n[ 5 ] = { 7 }; (d) int n[ 5 ] = { 6, 6, 6 };

(a)

6.41. The _____ is the average value of a set of data items. a) mean b) median c) mode d) matrix

(a)

6.7 Case Study: Computing Mean, Median and Mode Using Arrays 6.40 In order to calculate the __________ of an array of values, the array must be sorted. (a) median (b) mode (c) mean (d) (a), (b), and (c)

(a)

6.9. Which statement is false? a) The brackets used to enclose the subscript of an array are not an operator in C. b) To refer to a particular element in an array, we specify the name of the array and the position number of the element in the array. c) The position number within an array is more formally called a subscript. d) "Array element seven" and the "seventh element of an array" do not mean the same thing. This is a frequent source of off-by-one errors.

(a)

7.13. The __________, or address operator, is a unary operator that returns the address of its operand. a) & b) && c) * d) **

(a)

7.23. If array name arrayName is passed to a function, C automatically passes __________. a) &arrayName[ 0 ] b) arrayName[ 1 ] c) arrayName[ 0 ] d) *arrayName

(a)

7.25. Which statement is false? a) It is necessary to include names of pointer arguments in function prototypes. b) A function receiving an address as an argument must define a pointer parameter to receive the address. c) The compiler does not distinguish between a function that receives a pointer and a function that receives a single-subscripted array. d) The function must "know" whether it is receiving a single-subscripted array or simply a single variable for which it is to perform simulated call by reference.

(a)

7.29 What method should be used to pass an array to a function that does not modify the array and only looks at it using array subscript notation? (a) a constant pointer to constant data (b) a constant pointer to nonconstant data (c) a nonconstant pointer to constant data (d) a nonconstant pointer to constant data

(a)

7.33. The highest level of data access is granted by a a) non-constant pointer to non-constant data. b) non-constant pointer to constant data. c) constant pointer to non-constant data. d) constant pointer to constant data.

(a)

7.45 Comparing pointers and performing arithmetic on them is meaningless unless (a) they point to members of the same array (b) they point to arrays of the same type (c) they point to arrays of equal size (d) they point to different locations

(a)

7.5 Using the const Qualifier with Pointers 7.26 A function that modifies an array by using pointer arithmetic to process every value should have a parameter that is (a) a nonconstant pointer to nonconstant data (b) a nonconstant pointer to constant data (c) a constant pointer to nonconstant data (d) a constant pointer to constant data

(a)

7.58. Which statement about the parameter definition int (*compare)( int, int ) is false? a) It defines a parameter that is a pointer to a function that receives two integer arguments and returns a pointer to an integer as a result. b) Parentheses are needed around *compare because * has a lower precedence than the parentheses enclosing the function parameters. c) Without the parentheses it would have defined a function that receives two integers and returns a pointer to an integer. d) The corresponding parameter in the function prototype would ordinarily be int (*)( int, int )

(a)

7.8 Pointer Expressions and Pointer Arithmetic 7.42 Which of the following can have a pointer as an operand? (a) ++ (b) *= (c) % (d) /

(a)

3.57 In which of the following is y not equal to 5 after execution? x is equal to 4. (a) y = 5; (b) y = x++; (c) y = ++x; (d) y = x = 5;

(b)

3.11 Assignment Operators 3.54 If x = 3, which of the following sets x to 7? (a) x *= 4; (b) x += 4; (c) x =+ 4; (d) x + 4 = x;

(b)

3.29. Indentation in the if selection statement is ________. (a) always mandatory (b) always optional (c) only mandatory if there is more than one statement following the if statement (d) only optional if there is more than one statement following the if statement

(b)

3.31. Which statement is true about the contents of a correct diamond symbol in a correct flowchart. a) It must contain an expression that evaluates to zero or one. b) It must contain a condition or expression that can be either true or false. c) It must contain relational operators. d) It must contain equality operators.

(b)

3.34. Which statement is false? a) A compound statement can be placed anywhere in a program that a single statement can be placed. b) The if selection statement can have only one statement in its body. c) A set of statements contained within a pair of braces ({ and }) is called a compound statement. d) An if slection statement can have a compound statement in its body.

(b)

3.36 Which of the following will generate an error? (a) if ( answer == 7 ) printf( "correct" ); else printf( "incorrect" ); (b) printf( answer == 7 ? "correct" : "incorrect" ); (c) printf( "%s", answer == 7 ? "correct" : "incorrect" ); (d) answer == 7 ? printf( "correct" ) : printf( "incorrect" );

(b)

3.38. Placing a semicolon after the parenthesized condition in an if statement leads to a __________ error in single-selection if statements and a __________ error in double-selection if statements. a) logic, logic b) logic, syntax c) syntax, logic d) syntax, syntax

(b)

3.39. The empty statement is represented by placing __________ where a statement would normally be. a) empty b) ; c) null d) :

(b)

3.40. Which statement is false? a) A compound statement may contain definitions. b) A block may optionally contain definitions. c) A block that contains definitions can be used anywhere that a compound statement can be used. d) A compound statement that contains definitions is called a block

(b)

3.9 Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 2: Sentinel-Controlled Repetition 3.46 Indefinite repetition is controlled by a (a) counter (b) sentinel value (c) data value (d) non-constant condition

(b)

4.10 Logical Operators 4.47 In C, the condition 4 > y > 1 (a) evaluates correctly (b) does not evaluate correctly and should be replaced by ( 4 > y && y > 1 ) (c) does not evaluate correctly and should be replaced by ( 4 > y & y > 1 ) (d) does not evaluate correctly and should be replaced by ( 4 > y || y > 1 )

(b)

4.12 Structured Programming Summary 4.58 The ____________, __________, and ____________ are the only three forms of control necessary. (a) switch, if, else (b) sequence, selection, repetition (c) break, continue, if...else (d) for, while, do...while

(b)

4.12. Which data type should normally not be used to control a counting loop? a) int b) float c) short d) long

(b)

4.23. A program contains a for-loop with the following for header: for(counter = 1; ; counter++) The programmer's intent was most likely to create a) a syntax error b) an infinite loop c) a logic error d) a divide-by-zero error

(b)

4.27. Which statement regarding for statements is false? a) In a for statement, the initialization, loop-continuation condition, and increment can contain arithmetic expressions. b) The increment must be greater than zero. c) If the loop-continuation condition is initially false, the body of the loop is not performed. d) It is common to use the control variable for controlling repetition while never mentioning it in the body of the loop.

(b)

4.31. The for statement header for ( i = 1; i < 100; i++ ) performs the body of the loop for a) values of the control variable from 1 to 100 in increments of 1. b) values of the control variable from 1 to 99 in increments of 1. c) values of the control variable from 0 to 100 in increments of 1. d) values of the control variable from 0 to 99 in increments of 1.

(b)

4.32. What is the highest value assumed by the loop counter in a correct for statement with the following header? for ( i = 7; i <= 72; i += 7) a) 7 b) 77 c) 70 d) 72

(b)

4.39 In a switch statement (a) a break is required after each case (b) multiple actions do not need to be enclosed in braces (c) a default case is required (d) a break is required after the default case

(b)

4.4 ________ repetition is sometimes called indefinite repetition. (a) counter-controlled (b) sentinel-controlled (c) variable-controlled (d) none of these

(b)

4.40. Which statement regarding the switch statement is false? a) It is appropriate for algorithms that contain a series of decisions in which a variable or expression is tested separately for each of the constant integral values it may assume. b) The default case is required. c) The default case must be at the bottom of the switch after all the non-default cases. d) Many cases may all invoke the same code.

(b)

4.43 The following program segment will int counter = 1; do { printf( "%i ", counter ); } while ( ++counter <= 10 ) ; (a) print the numbers 1 through 11 (b) print the numbers 1 through 10 (c) print the numbers 1 through 9 (d) cause a syntax error

(b)

4.48 The OR (||) operator (a) has higher precedence than the AND (&&) operator (b) stops evaluation upon finding one condition to be true (c) associates from right to left (d) is a ternary operator

(b)

4.8 The statement while ( -- counter >= 1 ) printf( "%s\n", counter % 2 ? "even" : "odd" ); can not be rewritten as (a) while ( -- counter >= 1 ) if ( counter % 2 ) printf( "even" ); else printf( "odd" ); (b) while ( counter >= 1 ) if (counter % 2) printf( "even" ); else printf( "odd" ); --counter; (c) while ( counter >= 1 ) { if ( counter % 2 ) printf( "even" ); else printf( "odd" ); --counter; } (d) do { printf( "%s\n", counter % 2 ? "odd" : "even" ); --counter; }while ( counter >= 2 );

(b)

4.9 Which of the following is a bad programming practice? (a) indenting the statements in the body of each control structure (b) using floating-point values as the counter in counter-controlled repetition (c) using more than two levels of nesting (d) placing vertical spacing above and below control structures

(b)

5.10 Random Number Generation 5.40 The rand function generates a data value of the type (a) unsigned int (b) int (c) long int (d) short int

(b)

5.11. If a = 7.0, b = 7.0 and c = 6.0, then what is printed by printf( "%.2f", sqrt( a + b * c ) ); a) 49 b) 7.00 c) 7 d) 49.00

(b)

5.12. What is the value of fabs( -5.0 )? a) 5 b) 5.0 c) -5 d) -5.0

(b)

5.28. Placing a semicolon after the right parenthesis enclosing the parameter list of a function definition is a __________ error. a) logic b) syntax c) fatal runtime d) nonfatal runtime

(b)

5.3. Which is not an ANSI standard library function a) printf b) main c) scanf d) pow

(b)

5.30. Which statement is false? a) Every block is a compound statement. b) Every compound statement is a block. c) Blocks can be nested. d) Compound statements can be nested.

(b)

5.37. Which standard library header file contains function prototypes for conversions of numbers to text and text to numbers, memory allocation, random numbers and other utility functions. a) <stdarg.h> b) <stdlib.h> c) <stdutl.h> d) <stddef.h>

(b)

5.46 A compiler can ignore the storage class specifier _______. (a) auto (b) register (c) static (d) extern

(b)

5.48. Which is not an attribute of a variable a) name b) definition c) type d) value

(b)

5.52. Global variables and function names are of storage class __________ by default. a) register b) extern c) static d) auto

(b)

5.56. Which is not a scope for an identifier? a) function scope b) record scope c) block scope d) function-prototype scope

(b)

5.58 What value does function mystery return when called with a value of 4? int mystery ( int number ) { if ( number <= 1 ) return 1; else return number * mystery( number - 1 ); } (a) 1 (b) 24 (c) 0 (d) 4

(b)

5.59 Recursion is memory-intensive because (a) it must occur numerous times before it terminates (b) previous function calls are still open when the function calls itself and the arguments of these previous calls still occupy space on the call stack (c) many copies of the function code are created (d) it requires large data values

(b)

5.7. Functions are __________ by a function call. a) inveigled b) invoked c) internalized d) inverted

(b)

5.9 Calling Functions: Call by Value and Call by Reference 5.38 When arguments are passed by __________, the caller allows the called function to modify the original variable's value. (a) value (b) reference (c) both a and b (d) none of these

(b)

6.15 Strings can not (a) be initialized using string literals (b) end in a character other than the null character (c) be initialized with initializer lists (d) be treated as arrays of characters

(b)

6.29. Which statement is false? a) A static local variable exists for the duration of the program. b) A static local variable is visible only in the control structure in which it is defined. c) A static local array is not created and destroyed each time the function is entered and exited, respectively. d) Arrays that are defined static are automatically initialized once at compile time.

(b)

6.32 To prevent modification of array values in a function (a) the array must be defined static in the function (b) the array parameter can be preceded by the const qualifier (c) a copy of the array must be made inside the function (d) the array must be passed call-by-reference

(b)

6.36. Which statement is true? a) Entire arrays are passed simulated call by reference and individual array elements are normally passed simulated call by reference. b) Entire arrays are passed simulated call by reference and individual array elements are normally passed call by value. c) Entire arrays are passed call by value and individual array elements are normally passed simulated call by reference. d) Entire arrays are passed call by value and individual array elements are normally passed call by value.

(b)

6.38. Which statement about the bubble sort is false? a) It is easy to program. b) It is a high-performance sort. c) It compares only adjacent elements with one another. d) The bubble sort compares successive pairs of elements.

(b)

6.42. Calculating which of the following normally requires the data to be sorted first a) mean b) median c) mode d) total

(b)

6.48. A sorted array of a million elements can be searched by a binary search in __________ or fewer comparisons. a) 10 b) 20 c) 30 d) 999,999

(b)

6.5 Assuming that int a has a value of 3 and that integer array b has 7 elements, what is the correct way to assign the value of the sum of 3 and the third element, to the fifth element of the array? (a) b[ a + 1 ] = b[ a ] + 3; (b) b[ a + 1 ] = b[ a - 1 ] + 3; (c) b[ a ] + 1 = b[ a + 3]; (d) b[ a + 2 ] = b[ a ] + 3;

(b)

6.5 Passing Arrays to Functions 6.30 Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed __________. (a) call-by-value, call-by-reference (b) call-by-reference, call-by-value (c) call-by-value, call-by-value (d) call-by-reference, call-by-reference

(b)

6.54. Which initialization is not performed by the following definition? int b[ 2 ][ 2 ] = { { 1 }, { 3, 4 } }; a)b[ 0 ][ 0 ] is set to 1 b) b[ 0 ][ 1 ] is set to 1 c) b[ 1 ][ 0 ] is set to 3 d) b[ 1 ][ 1 ] is set to 4

(b)

6.9 Multiple-Subscripted Arrays 6.49 A double subscripted array element incorrectly referenced as a[ x, y ] is actually evaluated as (a) a[ x ][ y ] (b) a[ y ] (c) a[ x ] (d) a[ 0 ]

(b)

7.14. The statement y = &yPtr; a) assigns the address of the variable y to pointer variable yPtr. b) assigns the address of the variable yPtr to pointer variable y. c) is a compilation error. d) is a logic error.

(b)

7.2 Pointer Variable Definitions and Initialization 7.2 Pointers can not be used to (a) find the address of a variable in memory (b) reference values directly (c) simulate call-by-reference (d) manipulate dynamic data structures

(b)

7.22. When calling a function with arguments that should be modified, the __________ of those arguments are passed. a) memory b) addresses c) values d) complements

(b)

7.27 A function that prints a string should have a parameter that is (a) a nonconstant pointer to nonconstant data (b) a nonconstant pointer to constant data (c) a constant pointer to nonconstant data (d) a constant pointer to constant data

(b)

7.31. Which of the following most closely reflects the principle of least privilege. a) Always grant a function at least enough access to the data in its parameters to accomplish its specified task. b) Always grant a function enough access to the data in its parameters to accomplish its specified task, but no more. c) Always grant a function the least amount of access to the data in its parameters. d) Never grant a function access to the data in its parameters.

(b)

7.32. Which statement is false? a) If a value should not change in the body of a function to which it is passed, the value should be defined const to ensure that it is not accidentally modified. b) Attempts to modify the value of a variable defined const are caught at execution time. c) One way to pass a pointer to a function is to use a non-constant pointer to non-constant data. d) It is dangerous to pass a non-pointer into a pointer argument.

(b)

7.41. An expression such as sizeof( arrayName ) / sizeof( double ) might typically be used to determine a) the size of an array b) the number of elements in an array c) the number of elements in half an array d) the size of an element of an array

(b)

7.47. Which statement is false? a) A pointer can always be assigned to another pointer of the same type. b) A cast operator must always be used to convert the pointer on the right of an assignment to the pointer type on the left of the assignment. c) Variables of all pointer types can be assigned a pointer to void. d) A pointer to void can be assigned a pointer of any type.

(b)

7.5. A non-pointer variable name __________ references a value and a pointer variable name __________ references a value. a) directly, directly b) directly, indirectly c) indirectly, directly d) indirectly, indirectly

(b)

7.54. Which statement about the algorithm we presented in Section 7.10 of the text for shuffling a deck of cards is true? a) It is guaranteed to terminate. b) It could execute indefinitely. c) It is efficient. d) It uses a one-dimensional array of 52 cards.

(b)

7.56 ( *max )( num1, num2, num3 ); (a) is the header for function max (b) is a call to function max (c) is the prototype for function max (d) is part of a definition of a pointer to the function max

(b)

7.6 Bubble Sort Using Call-by-Reference 7.37. Which statement is false? a) The notations int *array and int array[] are interchangeable. b) Function prototypes may not be placed inside functions. c) Good advice: To encourage software reusability, when passing an array, also pass the size of the array. d) Global variable violate the principle of least privilege.

(b)

7.7. Referencing a value through a pointer is called __________. a) interdiction b) indirection c) intermediation d) redirection

(b)

7.8. Which statement about pointers is false. a) They can be defined to point to objects of any data type. b) The indirection operator * distributes to all comma-separated variable names in a definition. c) The letters Ptr in a pointer variable name are optional. d) A pointer may be initialized to 0, NULL or an address.

(b)

3.20. The __________ selection statement performs an action if a condition is true and performs a different action if the condition is false. a) if b) when c) if ...else d) switch

(c)

3.23. The __________ is called a double selection structure. a) if b) when c) if ...else d) switch

(c)

3.27. Any C program we will ever need to build can be constructed from only __________ different types of control structures combined in only __________ ways. a) 7, 3 b) 6, 2 c) 7, 2 d) 6, 3

(c)

3.32. A correct decision symbols has __________ flowlines emerging from it. a) 4 b) 3 c) 2 d) 1

(c)

3.33. Which of the following statements correctly prints "Passed" if the student's grade is greater than or equal to 60 and "Failed" if the student's grade is less than 60? [The quotes, of course, should not print.] a) printf( "%s\n", grade >= 60 : "Passed" : "Failed" ); b) grade >= 60 : printf( "Passed\n" ) ? printf( "Failed\n" ); c) printf( "%s\n", grade >= 60 ? "Passed" : "Failed" ); d) grade >= 60 ? printf( "Passed\n" ) ? printf( "Failed\n" );

(c)

3.37 A statement is called a block ________. (a) if it is a compound statement (b) if it contains definitions (c) if it is a compound statement that contains definitions (d) if it does not contain definitions

(c)

3.42 How many times will the following program print hello? i = 1; while ( i <= 10 ) printf( "hello" ); (a) 10 (b) 8 (c) an infinite number of times (d) 0

(c)

3.45. Counter-controlled repetition is often called __________ repetition because the number of repetitions is known before the loop begins executing. a) indefinite b) sentinel c) definite d) determinate

(c)

3.5 The if Selection Statement 3.28. If grade has the value of 60 what will the following code print? if ( grade >= 60 ) printf("Passed"); (a) nothing (b) 60 (c) Passed (d) printf("Passed");

(c)

3.50 Which operation does not take place in the following example? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y; (a) implicit conversion (b) promotion (c) explicit conversion (d) truncation

(c)

3.51. Which of the following is not a synonym for "sentinel value." a) signal value b) dummy value c) counter value d) flag value

(c)

3.55. Which assignment expression is equivalent to c = c / 2 ? a) c / = 2 b) c / c = 2 c) c /= 2 d) c =/ 2

(c)

3.7 The while Repetition Statement 3.41 What is wrong with the following while loop? While (sum <= 1000) sum = sum + 30; (a) The parenthesis should be braces. (b) Braces are required around sum = sum +30;. (c) While should be while. (d) There should be a semicolon after While ( sum <=1000 ).

(c)

4.10. Which is not always required by counter-controlled repetition? a) The name of a control variable (or loop counter). b) The initial value of the control variable. c) The decrement by which the control variable is modified each time through the loop. d) The condition that tests for the final value of the control variable (i.e., whether looping should continue.

(c)

4.11. In the context of counter-controlled repetition, which of the following is not accomplished by the control-variable initialization statement? int c = 10; a) Names the control variable. b) Defines the control variable to be an integer. c) Specifies the sentinel value. d) Sets the initial value of the control variable to 10.

(c)

4.18. Using an incorrect relational operator or using an incorrect final value of a loop counter in the condition of a while or for statement is a frequent cause of __________errors. a) syntax b) compilation c) off-by-one d) divide-by-zero

(c)

4.19. The comma operator is most often used in __________ statements. a) while b) do ... while c) for d) switch

(c)

4.2.Which statement is used to skip the remainder of the body of a repetition struction and proceed with the next iteration of the loop? a) skip b) proceed c) continue d) jump

(c)

4.22. Omitting the expression before the first required semi-colon in a for "header" is likely to cause a(n) __________ error. a) syntax b) infinite loop c) logic d) divide-by-zero

(c)

4.28. Which statement about a correct for statement with an initialization expression, a loop-continuation test, an increment expression and a loop body is false? a) The incrementing is performed each time through the loop. b) The loop-continuation test is evaluated each time through the loop. c) The initialization is performed each time through the loop. d) The increment expression is performed after the loop body.

(c)

4.33. What is produced by a for statement with a correct body and with the following header for ( i = 20; i >= 2; i += 2 ) a) a syntax error b) a divide-by-zero error c) an infinite loop d) the even values of i from 20 down to 2.

(c)

4.36. Which statement is true? a) Use float variables to perform monetary calculations in C. b) Use double variables to perform monetary calculations C. c) Monetary calculations can be performed in C. d) Printing with %.2f guarantees correct monetary calculations in C.

(c)

4.44. Which statement is true? a) The do ... while repetition statement is an alternate notation for the while repetition statement; these statements function identically. b) The do ... while repetition statement tests the loop-continuation condition before the loop body is performed. c) The loop body of a correct do ... while repetition statement is always executed at least once. d) The braces delineating the body of a do ... while statement are always required.

(c)

4.5 for Statement: Notes and Observations 4.25 If the loop-continuation condition is initially false, ________. (a) the body portion of the loop is not performed (b) execution proceeds with the statement following the for statement (c) both a and b (d) none of the above

(c)

4.51 An example of a unary operator is (a) a relational operator (b) an assignment operator (c) an increment operator (d) a logical operator

(c)

4.52. Which statement is true? a) To test multiple conditions in the process of making a decision requires logical operators. b) The keywords for the logical operators are AND, OR and NOT. c) The logical AND of two expressions is true if and only if each of the conditions is true. d) Truth tables deal only with cases in which all conditions are truthful (i.e., true).

(c)

4.57. Which statement is false? a) Any expression in C that produces a value can be used in the decision portion of any control structure. b) When tested for truth or falsity, an expression that produces a nonzero value is treated as true. c) Assignments in C produce a value, namely the value that the left-hand side of the assignment had prior to the assignment. d) Operator == is for comparisons; operator = is for assignment.

(c)

4.59. Which statement is true? a) Connecting flowchart symbols arbitrarily always forms structured programs. b) In a structured program, control structures can be only stacked or sequenced. c) In the "Rules for Forming Structured Programs (and Structured Flowcharts)," the rule that states, "Any rectangle (action) can be replaced by any control structure" is called the "nesting rule." d) Any form of control ever needed in a C program can be expressed in terms of the while, do ... while and for statements.

(c)

4.6 Examples Using the for Statement 4.29 Which of the following for headers is not valid? (a) int i; for( i = 0; i < 10; i++ ) (b) int i = 0; for( ; i < 10; i++ ) (c) int i; for( ; ; i++) (d) int i = 0; for( ; i < 10; )

(c)

4.6. Which statement is true? a) Sentinel values are used to control repetition when the precise number of repetitions is known in advance. b) Sentinel values are used to control repetition when the loop does not include statements that obtain data each time the loop is performed. c) Sentinels must be distinct from regular data items. d) Sentinel-controlled repetition is often called definite repetition.

(c)

4.7 switch Multiple-Selection Statement 4.38 A switch statement should be used (a) as a single-selection structure (b) as a double-selection structure (c) when a variable may assume many different values which must be tested against (d) to replace all if and if...else statements

(c)

4.8 do...while Repetition Statement 4.42 If a do...while statement is used, (a) an infinite loop will not take place (b) the counter must be preincremented if it is also the condition (c) the body of the loop will execute at least once (d) an off-by-one error will not occur

(c)

5.1 Introduction & 5.2 Program Modules in C 5.1 All of the following are true of functions except: (a) they define specific tasks that can be used at many points in a program (b) a function call must specify the name and arguments of the function (c) the definition of a function is always visible to other functions (d) the implementation of a function is hidden from the caller

(c)

5.13 Which of the following is not included in <math.h>? (a) pow (b) floor (c) ln (d) log10

(c)

5.14 Recursion 5.57 A recursive function is a function that (a) returns a double (b) takes 3 arguments (c) calls itself (d) is inside of another function

(c)

5.16 Recursion vs. Iteration 5.63 Recursion is to the base case as iteration is to what? (a) the counter (b) a repetition structure (c) failure of the loop continuation test (d) a selection structure

(c)

5.16. Which statement is false? a) Each function should be limited to performing a single, well-defined task. b) If you cannot choose a concise name that expresses what a function does, it is possible that the function is attempting to perform too many diverse tasks. c) Every function should be broken into smaller functions. d) A function's parameters are local variables.

(c)

5.18 Using the following function definition, the parameter list is represented by A B( C ) { D } (a) A (b) B (c) C (d) D

(c)

5.2. Experience has shown that the best way to construct a program is from small pieces. This is called __________. a) bottom up b) the whole is greater than the sum of the parts c) divide and conquer d) recursion

(c)

5.21 Which of the following is not an indication that a function is too complex? (a) it has a large size (b) it has a large parameter list (c) its name is a clear reflection of its function (d) it performs multiple tasks

(c)

6.8. The first element in every array is the __________ element. a) null b) 1 c) 0 d) empty

(c)

5.22 Which of the following functions does not contain any errors? (a) void printnum ( int x ) { print( "%i", x ); return x; } (b) int cube( int s ) { int s; return ( s * s * s ); } (c) double triple ( float n ) return ( 3 * n ); (d) double circumference ( int r ); return ( 3.14 * 2 * r );

(c)

5.23. int square( int ); is an example of a function __________. a) datatype b) stereotype c) prototype d) proceduretype

(c)

5.25. Which statement is true? a) Omitting the return value type in a function definition causes a syntax error if the function prototype specifies a return type other than double. b) Forgetting to return a value from a function that is supposed to return a value is a compilation error. c) Returning a value from a function whose return type is void is a syntax error. d) The return type for main must be omitted.

(c)

5.29. Which statement is true? a) The type of every parameter in a function parameter list must be included. b) The type of every argument in a function call must be included. c) It is not incorrect to use the same names for the arguments passed to a function and the corresponding parameters in the function definition. d) Defining a function parameter again as a local variable within the function is a logic error.

(c)

5.35. The forcing of arguments to the appropriate types is commonly called __________. a) conversion b) casting c) coercion d) transmogrification

(c)

5.39. Which statement is true? a) When an argument is passed call by reference, a copy of the argument's value is made and passed to the called function. b) With call by reference, changes to the passed value do not affect the original variable's value in the calling functions. c) Call by value should be used whenever the called function does not need to modify the value of the caller's original value. d) Call by value should only be used with trusted called functions that need to modify the original variable.

(c)

5.42 In the expression n = a + rand() % b; (a) b is the shifting value (b) a is the scaling value (c) b is equal to the width of the desired range of integers (d) both (a) and (c)

(c)

5.54 The only identifiers that can be reused elsewhere in a program without any ambiguity are (a) global variables (b) static local variables (c) those in the parameter list of a function prototype (d) those in the parameter list of a function definition

(c)

5.60. Which statement is false? a) A recursive function is a function that calls itself either directly or indirectly through another function. b) A recursive function knows how to solve only one or more base cases. c) The recursion step executes after the original call to the function terminates. d) In order for the recursion to eventually terminate, each time the function calls itself with a slightly simpler version of the original problem, this sequence of smaller and smaller problems must eventually converge on a base case.

(c)

5.62. Which statement is false? a) The ANSI C standard does not specify the order in which the operands of most operators are to be evaluated. b) The ANSI C standard specifies the order of evaluation of operators &&, ||, comma, and ?:. c) A program that evaluates Fibonacci numbers recursively achieves high performance because of exponential complexity. d) Programs that depend on the order of evaluation of the operands of operators other than &&, ||, comma, and ?: can function differently on systems with different compilers.

(c)

5.65. Which statement is false? a) Both recursion and iteration are based on a control structure. b) Both iteration and recursion involve repetition. c) Iteration with sentinel-controlled repetition and recursion each gradually approach termination. d) Both iteration and recursion can occur infinitely.

(c)

5.7 Function Call Stack and Activation Records 5.8 Header Files 5.36 Each standard library has a corresponding __________. (a) function (b) variable type (c) header file (d) cd-rom

(c)

6.1 Introduction 6.1. Arrays are data structures consisting of related data items of the same __________. a) sort order b) subscript c) type d) element

(c)

6.13 Constant variables (a) can be assigned values in executable statements (b) do not have to be initialized when they are defined (c) can be used to specify array sizes, thereby making programs more scalable (d) can be used to specify array sizes, but this makes programs harder to understand

(c)

6.16 Assume string1 is a character array. Which of the following operations does not produce a string? (a) string1[] = "test"; (b) string1[] = { 't', 'e', 's', 't', '\0' }; (c) string1[] = { 't', 'e', 's', 't' }; (d) string1[] = " ";

(c)

6.22. Which statement is true? a) A symbolic constant is an identifier that is replaced with replacement text by the C preprocessor after the program is compiled. b) Using symbolic constants to specify array sizes makes programs run faster. c) Preprocessor directives are not C statements. d) The #define preprocessor directive must end in a semicolon.

(c)

6.3. Lists, queues, stacks and trees are __________ data structures that may grow and shrink as programs execute. a) flexible b) automatic c) dynamic d) static

(c)

6.35. The special conversion specifier for printing addresses is __________. a) %a b) %m c) %p d) %loc

(c)

6.39. A bubble sort of 1000 elements requires a maximum of __________ passes. a) 1001 b) 1000 c) 999 d) 998

(c)

6.43. The __________ is the value that occurs most frequently in the data. a) mean b) median c) mode d) master

(c)

6.45 The maximum number of comparisons needed for the binary search of a 2000 element array is (a) 9 (b) 15 (c) 11 (d) 14

(c)

6.46. Which of these is generally thought of as a high-performance technique? a) bubble sort b) linear search c) binary search d) iteration

(c)

6.50 Given the following definitions, what is the value of b[ 1 ][ 0 ]? int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } }; (a) 0 (b) 1 (c) 3 (d) this isn't a valid definition

(c)

6.8 Searching Arrays 6.44 The binary search technique (a) is better suited to small arrays (b) is better suited to unsorted arrays (c) can only be used on a sorted array (d) is slower than a linear search

(c)

7.10 Arrays of Pointers 7.51 A string array (a) stores an actual string in each of its elements (b) can only provide access to strings of a certain length (c) is actually an array of pointers (d) is always less memory efficient than an equivalent double-subscripted array

(c)

7.11 Case Study: Card Shuffling and Dealing Simulation 7.53 An algorithm that could execute for an unknown amount of time because it depends on random numbers to exit a function may (a) have a redundancy. (b) get caught in an infinite loop. (c) suffer from indefinite postponement. (d) issue a compiler error.

(c)

7.12 Three of the following expressions have the same value. Which of the following's value is different from the others? (a) *&Ptr (b) &*Ptr (c) *Ptr (d) Ptr

(c)

7.15. Which statement is false? a) The operand of the address operator must be a variable. b) The address operator cannot be applied to constants or to expressions. c) The address operator can be applied to variables defined with the storage class register. d) The address operator can be applied to variables defined with the storage class static.

(c)

7.16. Which statement is false? a) The unary * operator is called the indirection operator or the dereferencing operator. b) The operand of the unary * operator must be a pointer. c) The unary * operator returns the value of its operand. d) Placing a * operator before a pointer dereferences the pointer.

(c)

7.18. The unary * and __________ are complements of one another. a) / b) ^ c) & d) |

(c)

7.20 When a compiler encounters a function parameter for a single-subscripted array of the form int a[], it converts the parameter to (a) int a (b) int &a (c) int * a (d) int * const a

(c)

7.21. Which statement is false. a) All function calls in C pass arguments call-by-value. b) Simulated call-by-reference enables a called function to modify variables in the calling function. c) Call-by-value is always more efficient than simulated call-by-reference. d) In C, programmers use pointers and the indirection operator to simulate call-by-reference.

(c)

7.28 An array name is (a) a nonconstant pointer to nonconstant data (b) a nonconstant pointer to constant data (c) a constant pointer to nonconstant data (d) a constant pointer to constant data

(c)

7.3 Pointer Operators 7.10 The & operator can be applied to (a) constants (b) variables defined with the storage class register (c) variables defined with the storage class static (d) rvalues

(c)

7.30. Which statement is false? a) The const qualifier enables the programmer to inform the compiler that the value of a particular variable should not be modified. b) The const qualifier did not exist in early versions of C; it was added to the language by the ANSI C committee. c) Using the const qualifier typically violates the principle of least privilege d) Adding const to C programs that do not use it presents significant opportunities for improvement in the software engineering of that code.

(c)

7.35. When a structure must be passed to a function, we can use pointers to constant data to get the performance of a call by __________ and the protection of a call by __________. a) value, value b) value, reference c) reference, value d) reference, reference

(c)

7.39 Which of the following gives the number of elements in the array int r[ ]? (a) sizeof ( r ) (b) sizeof ( *r ) (c) sizeof ( r ) / sizeof ( int ) (d) sizeof ( *r ) / sizeof ( int )

(c)

7.4. Pointers are variables that contain __________ as their values a) strings b) flowlines c) memory addresses d) directions

(c)

7.43 Given that k is an integer array starting at location 2000, kPtr is a pointer to k, and each integer is stored in 4 bytes of memory, what location does kPtr + 3 point to? (a) 2003 (b) 2006 (c) 2012 (d) 2024

(c)

7.44 A pointer can not be assigned to (a) another pointer of the same type (b) a pointer to void (c) a pointer of a type other than its own type and void (d) any other pointer by using the cast operator

(c)

7.46. Which statement is false? a) A pointer may be incremented or decremented. b) An integer may be added to a pointer. c) All operators normally used in arithmetic expressions, assignment expressions and comparison expressions are valid in conjunction with pointer variables. d) A pointer may not be added to a pointer.

(c)

7.9 Relationship Between Pointers and Arrays 7.48 Assuming that t is an array and tPtr is a pointer to that array, what expression refers to the address of the fourth element? (a) *( tPtr + 3 ) (b) tPtr[ 3 ] (c) &t[ 3 ] (d) *( t + 3 )

(c)

3.21. The __________ selection statement performs one of many different actions, depending on the value of an expression. a) if b) when c) if ...else d) switch

(d)

3.24. The __________ is called a multiple selection structure. a) if b) when c) if ...else d) switch

(d)

3.25. Which is not a repetition structure? a) while b) do ...while c) for d) do ...for

(d)

3.30. The C compiler ignores __________ characters like blanks, tabs and newlines used for indentation and vertical spacing. a) transparent b) translucent c) white d) whitespace

(d)

3.43. Consider the following correct segment of a correct C program: p = 2; while ( p < 2000 ) p = 2 * p; What is the value of p after this while loop completes its execution? a) 1023 b) 1024 c) 2047 d) 2048

(d)

3.47 A fatal logic error is always caused by: (a) not initializing variables before executing a repetition structure (b) choosing a sentinel value that is also a data value (c) using a counter variable in a calculation after the loop (d) an attempt to divide by zero

(d)

3.49 What is the final value of x after performing the following operations? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y; (a) 8.25 (b) 5.5 (c) 5 (d) 8

(d)

3.53. Which statement is true? a) With nested control structures, the inner control structure is executed in sequence after the outer control structure completes its own execution. b) With nested control structures, the inner control structure is executed exactly once. c) Experience has shown that the most difficult part of solving a problem on a computer is converting an already correct algoithm to a C program. d) A double-selection structure can be nested in a repetition structure.

(d)

3.58 Which statement is true? a) The expression ++(a + 1) adds 2 to a. b) The expression **a multiplies a by 1. c) The ANSI standard for the C programming language specifies the order in which each operator's operands will be evaluated. d) The expression --(abc * 37) is a syntax error

(d)

4.13. Which statement is generally false? a) Control counting loops with integer values. b) Indent the statements in the body of each control structure for clarity. c) Put a blank line before and after each major control structure to make it stand out in the program. d) The more deeply nested a program is, the easier it is to understand.

(d)

4.16. Which of the following is not specified by the following correct code segment: for ( c = 1; c <= 10; c++ ) a) initial value of the loop counter b) loop continuation test c) increment of the loop counter d) body statement of the loop

(d)

4.17. A programmer writes a for statement to count from 1 to 10 and explicitly mentions the 1 and the 10 in the for "header." Which relational operator would probably be used in the loop-continuation test? a) > b) >= c) < d) <=

(d)

4.21. What happens if the loop-continuation test is omitted in a for-statement? a) C assumes the condition is false, so the loop terminates. b) A syntax error occurs. c) C assumes the condition is true, so the loop executes one more time, then terminates. d) An infinite loop.

(d)

4.24. Which of the following is an incorrect expression to increment c by 1 in the increment expression of a for "header?" a) c += 1 b) ++c c) c++ d) c + 1 = c

(d)

4.26 If the increment of the for statement is ________ then the loop counts ________. (a) true, downwards (b) false, downwards (c) positive, downwards (d) negative, downwards

(d)

4.3 Counter-Controlled Repitition 4.7 Which of the following does counter controlled repetition not require? (a) an initial value (b) a condition that tests for the final value (c) an increment or decrement by which the control variable is modified each time through the loop (d) counter controlled repetition requires all of the above

(d)

4.30 Float and double variables should be used (a) to perform monetary calculations. (b) as counters. (c) with relational operators. (d) as imprecise representations of numbers.

(d)

4.35. Which expression raises x to the y power a) x ** y b) x ^ y c) x pow y d) pow( x, y )

(d)

5.43 srand (a) should be called before each call to rand (b) should be used instead of rand to generate truly random numbers (c) is unnecessary in C (d) can use time as an automatically input seed value

(d)

4.37. Which statement is true? a) The conversion specifier %7.2f prints a floating-point value with a field width of 10 positions. b) The conversion specifier %7.2f prints a floating-point value with 7 positions to the left of the decimal point. c) The conversion specifier %7.2f prints a floating-point value with 5 positions to the left of the decimal point. d) The conversion specifier %7.2f prints a floating-point value with 4 positions to the left of the decimal point.

(d)

4.4 for Repetition Statement 4.14 Which of the following is not true? (a) the three expressions in the for statement are optional. (b) the initialization and increment expressions can be comma-seperated lists. (c) you must define the control variable outside of the for loop. (d) All of the above are true.

(d)

4.41. Which statement is true? a) EOF must have the value 1 on all C systems. b) EOF is a symbolic constant defined in the <symbol.h> header file. c) EOF is a symbolic variable defined in the <stdio.h> header file. d) EOF is a symbolic integer constant defined in the <stdio.h> header file.

(d)

4.46. Which statement is true? a) The break statement causes an immediate exit from a while, for, do ... while or if ... else statement. b) The continue statement is designed for use with the while, for, do ... while or switch statements. c) An equivalent while statement for any for statement can always be formed. d) The break statement causes an immediate exit from a while, for, do ... while or switch statement.

(d)

4.49 The expression if ( num != 65 ) can not be replaced by: (a) if ( num > 65 || num < 65 ) (b) if !( num == 65 ) (c) if (num - 65) (d) if !(num - 65)

(d)

4.5. Which statement is false? a) Counter-controlled repetion is sometimes called definite repetition. b) Sentinel-controlled repetition is sometimes called indefinite repetition. c) The sentinel value typically indicates "end of data." d) In counter-controlled repetition, the control variable is always incremented by 1 each time the group of instructions is performed.

(d)

4.50 An operator that associates from right to left is (a) != (b) , (c) () (d) ?:

(d)

4.53. Which statement is true? a) Operator || has a higher precedence than operator &&. b) In expressions involving operator ||, making the condition that is most likely to be false the leftmost condition can often reduce execution time. c) The logical negation operator is a binary operator. d) In expressions using operator &&, making the condition that is most likely to be false the leftmost condition can often reduce execution time.

(d)

4.56 Of the following, which is not a logic error? (a) Using the assignment (=) operator instead of the (==) equality operator to determine if two values are equal (b) Dividing by zero (c) Failing to initialize counter and total variables before the body of a loop (d) Using commas instead of the two required semicolons in a for header

(d)

4.9 break and continue Statements 4.45 Which of the following is false? (a) break and continue statements alter the flow of control. (b) continue statements skip the remaining statements in the body of the loop in which they are embedded. (c) break statements exit from the loop in which they are embedded. (d) continue and break statements may be embedded within all C++ structures.

(d)

5.10. What happens when you do not include math.h when using functions in the math library? a) compilation error b) execution error c) logic error d) strange results may occur

(d)

5.11 Example: A Game of Chance 5.12 Storage Classes 5.45 An identifier's storage class (a) determines the period during which that identifier exists in memory (b) determines whether an identifier in a multiple-source-file program is known only in the current source file or in any source file with proper definitions (c) determines where the identifier can be referenced in a program (d) all of the above

(d)

5.15 Example Using Recursion: The Fibonacci Series 5.61 Assuming the following pseudocode for the fibonacci series, what is the value of the 5th fibonacci number (i.e. fibonacci(5))? fibonacci( 0 ) = 0 fibonacci( 1 ) = 1 fibonacci( n ) = fibonacci( n - 1 ) + fibonacci( n - 2 ) (a) 0 (b) 1 (c) 3 (d) 5

(d)

5.15. Which is not a motivation for "functionalizing" a program? a) The divide-and-conquer approach makes program development more manageable. b) Software reusability—using existing building blocks to create new programs. c) Avoid repeating code. d) Execution performance—functionalized programs run faster.

(d)

5.20 Which of the following will not produce a syntax error? (a) Omitting a return type from a function definition if the function prototype specifies a return type other than int (b) Returning a value from a function defined as void (c) Defining a function parameter again inside a function (d) Using the same names for arguments passed to a function and the corresponding parameters in the function definition

(d)

5.24. As used in int square( int ); int is not a(n) __________. a) data type b) parameter type c) return type d) function prototype

(d)

5.27. The most concise notation to use to define function parameters x and y as double is __________. a) x, y b) x, double y c) double x, y d) double x, double y

(d)

5.3 Math Library Functions 5.8 All math library functions return the data type (a) long double (b) int (c) float (d) double

(d)

5.34. Which statement is false? a) The compiler uses function prototypes to validate function calls. b) Prior to ANSI C, C did not include function prototypes. c) A function prototype tells the compiler the type of data returned by the function, the number of parameters the function expects to receive, the types of these parameters and the order in which parameters of these types are expected. d) The designers of ANSI C++ borrowed the notion of function prototypes from the developers of C.

(d)

5.4 Functions 5.14 A valid reason for building programs out of functions is (a) that the divide-and-conquer approach facilitates program construction (b) that pre-existing functions can be used to create new programs (c) the avoidance of code repetition within a program (d) all of the above

(d)

5.41 A variable that can only have values in the range 0 to 65535 is a (a) four-byte int (b) four-byte unsigned int (c) two-byte int (d) two-byte unsigned int

(d)

5.6. Which statement is true? a) The boss function normally knows how the worker function performs its designated tasks. b) A worker function may not call other worker functions. c) "Hiding" of implementation details makes it difficult to understand software. d) The boss function is normally unaware when a worker function calls a function.

(d)

5.64 All of the following are reasons to use recursion except: (a) an iterative solution is not apparent (b) the resulting program is easier to debug (c) it more naturally mirrors the problem (d) it maximizes software performance

(d)

5.9. All functions in the math library return the data type __________. a) float b) int c) long d) double

(d)

6.11. Which definition tells the computer to reserve 12 elements for integer array c? a) c[ 12 ] int; b) int c [ 11 ]; c) c[ 11 ] int; d) int c[ 12 ];

(d)

6.17. Suppose a program contains the code for (i = 1; i < = 10; i++) n[ i ] = 0; Which statement about this code must be true? a) It contains an off-by-one error. b) It contains a syntax error. c) It is initializing the first 10 elements of an array. d) It is initializing successive elements of an array.

(d)

6.18. What's wrong with this code? int[] = ( 1, 2, 3, 4, 5); a) The array size must be specified in the square brackets. b) The parentheses should be square brackets. c) The square brackets should be curly braces. d) The parentheses should be curly braces.

(d)

6.19. If there are fewer initializers than elements in the array, the remaining elements are __________. a) deleted b) ignored c) initialized to empty d) initialized to zero

(d)

6.2 Arrays 6.4 An array is not (a) a consecutive group of memory locations (b) subscripted by integers (c) pointer-based (d) a dynamic entity

(d)

6.2. Arrays and structures are __________ entities in that they remain the same size throughout program execution. a) dynamic b) automatic c) register d) static

(d)

6.20. Which statement is true? a) Arrays are automatically initialized to zero. b) To initialize all array elements to zeros, the array definition must explicitly initialize each element to zero. c) Array elements can be initialized to zero by the array definition only at compile time. d) Definitions for automatic arrays initialize the arrays at execution time.

(d)

6.21. The following array definition int n[ 5 ] = { 32, 27, 64, 18, 95, 14 }; a) is correct b) causes a syntax error because there are only five initializers and six array elements. c) causes a logic error because there are only five elements but there are six initializers. d) causes a syntax error because there are six initializers but only five array elements.

(d)

6.25. Which statement is false? a) C has no built-in bounds checking to prevent the computer from referring to an array element that does not exist. b) The programmer is responsible for implementing array bounds checking. c) Referring to an element outside the array bounds is a syntax error. d) Referring to an element outside the array bounds is a logic error.

(d)

6.26. Which statement is false? a) The string termination character is called the null character. b) The string "string" actually occupies 7 characters in memory. c) The character representation of the last character in memory of a string is '\0'. d) A character array representing a string should be defined as large as the actual number of characters in the string minus the terminating character; C automatically provides the space for the terminating character.

(d)

6.27. The definition char string1[] = "first"; is equivalent to a) character string1[] = { 'f', 'i', 'r', 's', 't', '\0' }; b) char string1 = { 'f', 'i', 'r', 's', 't', '\0' }; c) char string1[] = { 'f', 'i', 'r', 's', 't' }; d) char string1[] = { 'f', 'i', 'r', 's', 't', '\0' };

(d)

6.28. Which statement is false? a) Function scanf reads characters into memory from the keyboard until the first input whitespace character is encountered. b) Function scanf can write beyond the boundary of the array into which input is being placed. c) Function printf does not care how large the array it is printing is. d) When using scanf, you must always precede with the & operator the name of each variable into which inputs are being placed.

(d)

6.3 Defining Arrays 6.10 Which statement would be used to define a 10 element integer array c? (a) Array c = int[ 10 ]; (b) c = int[ 10 ]; (c) int Array c[ 10 ]; (d) int c[ 10 ];

(d)

6.34. Which statement is false? a) C automatically passes arrays to functions using simulated call by reference. b) When C passes an array to a function, the called function normally can modify the element values in the caller's original array. c) The name of an array is actually the address of the first element of the array. d) When an array is passed in a function call, the calling function knows precisely where in the called function's memory the passed array is.

(d)

6.47. Which of the following statements is false? a) The linear searching method works well for small arrays. b) The linear searching method works well for unsorted arrays. c) The binary search algorithm eliminates from consideration one half of the elements in a sorted array after each comparison. d) The binary search terminates only when the search key is equal to the middle element of a subarray.

(d)

6.51 Which of the following does not initialize all of its elements to 0? (a) int b[ 2 ][ 2 ]; b[ 0 ][ 0 ] = b[ 0 ][ 1 ] = b[ 1 ][ 0 ] = b[ 1 ][ 1 ]; (b) int b[ 2 ][ 2 ] = { 0 }; (c) int b[ 2 ][ 2 ]; for ( int i = 0; i < 2; i++ ) for (int j = 0; j < 2; j++ ) b[ i ][ j ] = 0; (d) all of the above initialize all of their elements to 0.

(d)

6.52. Which statement is false about multiple-subscripted arrays? a) C supports multiple-subscripted arrays. b) A common use of multiple-subscripted arrays is to arrange data into tables consisting of rows and columns. c) To identify a particular table element requires two subscripts. d) Every ANSI C system can support arrays with as many subscripts as the programmer chooses.

(d)

6.53. An array containing 3 columns and 4 rows is typically referred to as a __________. a) 12-element array b) 3-by-4 array c) 13-element array, because of the zero element d) 4-by-3 array

(d)

6.6 Sorting Arrays 6.37 Which statement about bubble sort is true? (a) a maximum of n passes are needed to sort the array, where n is the number of elements (b) swapping values requires two assignments (c) performance is maximized (d) the algorithm is very simple compared to other sorting procedures

(d)

6.6 Which of the following is not true? (a) the first element of an array is the zeroth (b) the last element of an array is the array size - 1 (c) the position number contained within square brackets is called a subscript (d) a subscript cannot be an expression.

(d)

6.7. An array is a group of memory locations related by the fact that they all have __________ name and __________ type. a) different, different b) same, different c) different same d) same, same

(d)

7.1 Introduction 7.1. Which statement about pointers is false? a) They are among C's most difficult capabilities to master. b) They enable programs to simulate call by reference. c) They are useful to create and manipulate dynamic data structures. d) They cannot be used to create data structures that do not grow and shrink at execution time.

(d)

7.11 All of the following could cause a fatal execution-time error except (a) dereferencing a pointer that has not been assigned to point to a specific address (b) dereferencing a pointer that has not been initialized properly (c) dereferencing a 0 pointer (d) dereferencing a nonpointer

(d)

7.12 Pointers to Functions 7.55 Which of the following is not true of pointers to functions? They (a) contain the starting address of the function code (b) are dereferenced in order to call the function (c) can be stored in arrays (d) can not be assigned to other function pointers

(d)

7.17. Which statement is generally false? a) Initializing pointers is optional. b) Dereferencing an uninitialized pointer could lead to a fatal execution time error. c) Deferencing an uninitialized pointer could accidentally modify important data. d) Derefencing an uninitialized pointer causes a syntax error.

(d)

7.24. When the __________ of a variable is passed to a function, the indirection operator (*) may be used in the function to modify the __________ at that location in the caller's memory. a) address, address b) value, address c) value, value d) address, value

(d)

7.3 Pointers may be assigned to which of the following? (a) all integer values (b) an address (c) NULL (d) both (b) and (c)

(d)

7.34. Which statement is false? a) Arrays and structures are aggregate data types. b) Structures in C are sometimes called records in other languages. c) A structure is capable of storing many related data items of different data types. d) Structures are always passed call by reference.

(d)

7.36. The least access privilege is granted by a __________ pointer to __________ data. a) non-constant, non-constant b) non-constant, constant c) constant, non-constant d) constant, constant

(d)

7.4 Passing Arguments to Functions by Reference 7.19 Which of the following is not a valid way to pass arguments to a function in C? (a) call-by-reference with reference arguments (b) call-by-value (c) call-by-reference with pointer arguments (d) call-by-value with pointer arguments

(d)

7.40. Which statement is false? a) Using global variables, instead of passing arguments, can increase program performance, but reduce effective software engineering. b) Hardcoding into a function the size of an array that will be passed as an argument rather than passing the size of the array as a parameter, reduces the software reusability of that function. c) sizeof is an operator that calculates the size of its argument in bytes at compile time. d) When applied to the name of an array, sizeof returns the number of elements in the array.

(d)

7.49 Consider the following function: void reverse( char * string1, const char * string2 ) { int stringsize = sizeof( string1 )/sizeof( char ); *( string1 + stringsize -1 ) = '\0'; string1 = string1 + stringsize - 2; for ( ; *string2 != '\0'; string1--, string2++ ) *string1 = *string2; } What method does the function use to refer to array elements? (a) array/subscript notation (b) array/offset notation (c) pointer/subscript notation (d) pointer/offset notation

(d)

7.50. If bPtr is assigned b (the name of an array), then array element b[ 3 ] can alternatively be referenced with the pointer expression __________. a) bPtr + 3 b) b[ bPtr + 3 ] c) *b [ bPtr + 3 ] d) *( bPtr + 3)

(d)

7.52. Which statement is false? a) In C, a string is essentially a pointer to its first character. b) Arrays may contain pointers. c) Each entry in an array of strings is actually a pointer to the first character of a string. d) The size of an array of strings is the sum of the lengths of the strings.

(d)

7.57. A pointer to a function contains __________. a) the address of the function's automatic variables b) the address of the function on the stack c) the address of the entry for that function in the System Function Table d) the address of the function in memory

(d)

7.6. The definition int *count; a) is a syntax error because only pointers can be defined with * notation b) is a compile-time error. c) is a logic error. d) is a correct definition of integer pointer count.

(d)

7.7 sizeof Operator 7.38 sizeof (a) is a binary operator (b) returns the total number of elements in an array (c) usually returns a double (d) returns the total number of bytes in an array

(d)

7.9. Which statement about pointers is false? a) A pointer with the value NULL points to nothing. b) NULL is a symbolic constant defined in the <stdio.h> header file. c) Initializing a pointer to 0 is equivalent to initializing a pointer to NULL, but NULL is preferred. d) The values 0 and 1 are the only values that can be assigned directly to a pointer variable.

(d)

1.12 BASIC, Visual Basic, Visual C++, Visual C# and .NET 1.28 BASIC was developed by professors at ___________. (a) Dartmouth College (b) Massachusetts Institute of Technology (c) Columbia University (d) Cornell University

(a)

1.13 What is bandwidth? (a) information carrying capacity (b) response time (c) the set of networking protocols (d) an error-control technique

(a)

1.15 Hardware Trends 1.32 Over the past decades which of the following has occurred? (a) hardware costs have fallen rapidly (b) software costs have fallen rapidly (c) hardware costs have risen rapidly (d) none of the above

(a)

1.16 A computer can directly understand only its own ___________. (a) machine language (b) assembly language (c) high-level language (d) none of the above

(a)

1.2 Which of the following is going to be the key programming methodology for the next decade? (a) object-oriented programming (b) structured programming (c) "legacy C code" (d) "live-code approach"

(a)

1.31 The linker creates __________. (a) an executable image (b) a preprocessor directive (c) object code (d) an input stream

(a)

1.4 Which of the following would not be considered hardware? (a) an operating system (b) a CPU (c) a keyboard (d) a disk

(a)

1.5 Computer programs are __________. (a) sets of control instructions (b) the information processed by the computer (c) the various devices (disks, memory, keyboard) that comprise a computer system (d) the people programming the computers

(a)

1.6 The Internet and the World Wide Web 1.11 An ancestor of today's Internet was _____________. (a) ARPAnet (b) e-mail (c) FORTRAN (d) Univac 1108

(a)

1.9 C++ 1.22 ________ are essentially reusable software components that model items in the real world. (a) objects (b) supersets (c) modules (d) developers

(a)

2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with _______________ let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d) <<

(a)

2.17 Which statement prints "hi" on the screen? (a) printf("hi"); (b) print "hi"; (c) printf "hi"; (d) none of the above

(a)

2.2 Which of the following must every C program have? (a) main (b) #include (c) /* (d) <stdio.h>

(a)

2.20. Which statement is false. a) Variables may be defined anywhere in the body of main. b) All variables must be defined. c) All variable definitions must include the name and data type of each variable. d) Several variable of the same data type may be defined in one definition.

(a)

2.28 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

(a)

2.33 Evaluate the expression 3 * 4 % 6 + 4 *5 (a) 20 (b) 26 (c) 12 (d) 32

(a)

2.4 Memory Concepts 2.28 Variable names actually correspond to __________. (a) locations in the computer's memory (b) operators (c) integers (d) data types

(a)

2.40 Which of the following is an equality operator? (a) == (b) = (c) > (d) >=

(a)

2.46. Which statement is false? a) The assignment operator associates from left to right. b) The arithmetic operators associate from left to right. c) The equality operators associate from left to right. d) The relational operators associate from left to right.

(a)

2.6 Decision Making: Equality and Relational Operators 2.39 C's 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

(a)

2.7. Which of the following statements about the inclusion of <stdio.h> is false? a) It is required. b) This header file contains information and declarations used by the compiler when compiling standard input/output library functions such as printf. c) This header file contains information that helps the compiler determine if calls to library functions have been made correctly. d) This header helps locate bugs in your program at compile time, rather than at execution time (when errors are usually more costly to correct).

(a)

3.10 How many types of control structures exist in C? (a) 3 (b) 7 (c) 5 (d) 2

(a)

3.13. Bohm and Jacopini's work demonstrated that all programs could be written in terms of only three control structures, namely sequence, __________ and repetition. a) selection b) serialization c) sorting d) searching

(a)

3.16. Flowchart symbols are connected by arrows called __________. a) flowlines b) flow of control c) flow delimiters d) darts

(a)

3.4 Pseudocode does not include __________. (a) definitions (b) input/output (c) action statements (d) control structures

(a)

1.1 Introduction 1.1 Which of the following statements is true? (a) hardware controls software (b) software commands the computer to perform actions and make decisions (c) Pascal and C are object oriented programming languages (d) ANSI is the international standards institute

(b)

1.12 The technique by ARPA to allow multiple users to send and receive information at the same time over the same communications paths is known as ___________. (a) electronic mail (b) packet switching (c) networking (d) multitasking

(b)

1.14 Typical C Program Development Environment 1.30 The compile stage is when ____________. (a) the object code is linked with code for functions in other files (b) the C program is translated into machine language code (c) the program is executed one instruction at a time (d) the program is placed in memory

(b)

1.16 Notes About C and This Book 1.34 What does KIS stands for? (a) Keep In Sync (b) Keep It Simple (c) Keep Iterating Stuff (d) Keyword Interpreted Sequence

(b)

1.17 Assemblers__________. (a) convert machine language into high-level language. (b) convert assembly language into machine language. (c) convert high-level language into machine language. (d) convert high-level language into assembler language.

(b)

1.18 Programs that directly execute high-level language programs without compiling are called __________. (a) assemblers (b) interpreters (c) compilers (d) translators

(b)

1.25 What language(s) Java is based on? (a) B and BCPL (b) C and C++ (c) Smalltalk (d) FORTRAN

(b)

1.3 Computer Organization 1.6 Which of the following is not one of the six logical units of a computer? (a) input unit (b) programmer unit (c) memory unit (d) output unit

(b)

1.4 Personal, Distributed, and Client/Server Computing 1.9 When computing is spread over networks rather than performed at a centralized location, this is known as __________. (a) multiprogramming (b) distributed computing (c) personal computing (d) batch processing

(b)

1.6 Machine Languages, Assembly Languages, and High-level Languages 1.15 Which of the following is not a general programming language type? (a) machine languages (b) low-end languages (c) assembly languages (d) high-level languages

(b)

2.12. In a printf, a backslash is printed by enclosing in quotes a) \ b) \\ c) /\ d) //

(b)

2.14. The escape sequence for horizontal tab is __________. a) \t ab b) \t c) \horizontaltab d) \T

(b)

2.18 The __________ sign is also known as the __________ operator. (a) +, assignment (b) =, assignment (c) *, stream manipulator (d) &, stream insertion

(b)

2.24. A(n) __________ error is caused when the compiler can not recognize a statement. a) logic b) syntax c) linkage d) execution

(b)

2.3 Every statement in C must end with a (a) period (.) (b) semicolon (;) (c) colon (:) (d) backslash (/)

(b)

2.31. Which of the following is false? a) Reading a value into a memory location destroys the previous value. b) Reading a value out of a memory location destroys that value. c) sum = integer1 + integer2; involves destructive read-in. d) The statement in part c) also involves nondestructive read-out.

(b)

2.34. Which statement is false? a) In algebra, we write ab to multiply a times b. b) In C, we write ab to multiply a times b. c) In C, the remainder operator is %. d) In C, integer division yields an integer result.

(b)

2.35. Which statement about C arithmetic is false? a) 6 / 3 yields 2 b) 5 / 2 yields 2.5 c) 7 % 3 yields 1 d) 6 % 3 yields 0

(b)

2.37. Which statement about precedence is false? a) Parentheses may be used to force the order of evaluation to occur in any sequence desired by the programmer. b) Nested, or embedded parentheses are evaluated last. c) Multiplication has a higher precedence than addition. d) Subtraction has a lower precedence than division.

(b)

2.38. Which expression is true? a) The expression a * (b + c) + c * (d + e) contains nested parentheses. b) The expression y = a * x * x + b * x + c is a second degree polynomial. c) The C standard library provides function power to perform exponentiation. d) When we say evaluation of an expression proceeds from left to right we are referring to the additivity of the operators.

(b)

2.42. Which statement is false? a) The relational operators associate left to right. b) An execution time error will occur if the two symbols in any of the operators ==, !=, >= and <= are separated by spaces. c) Confusing the == operator with = operator is typically an error. d) The equality operators associate left to right.

(b)

2.43. Which statement is false? a) Whitespace characters such as tabs, newlines and spaces are generally ignored by the C compiler. b) The statements in an if statement must be indented. c) Placing a blank line before and after every control structure can improve program readability. d) There can be (but should not be) more than one statement per line.

(b)

2.5 Arithmetic in C 2.32 Which operation will find the remainder when 15 is divided by 6? (a) 15 / 6 (b) 15 % 6 (c) 15 ^ 6 (d) 15 * 6

(b)

2.9. The pair of braces that delineate the body of main and the portion of the program between these braces is called a __________. a) function b) block c) statement d) header

(b)

3.14. Which statement is true? a) Unless directed otherwise, the computer automatically executes C statements one before the other. b) The sequence structure is essentially built into C. c) A flowchart is a pseudocode representation of an algorithm or a portion of an algorithm. d) Like pseudocode, flowcharts are useful for developing and representing algorithms, although flowcharts are preferred by most programmers.

(b)

3.3 Pseudocode 3.3 Which of the following is true of pseudocode programs? (a) they are executed by the computer (b) they help the programmer "think out" a program (c) they include definitions and all types of statements (d) all of the above are false

(b)

1.10 Programs and data used in client/server computing are stored on __________. (a) personal computers (b) supercomputers (c) file servers (d) local area networks

(c)

1.11 Fortran, COBOL, Pascal and Ada 1.26 Which of the following is not true about COBOL? (a) it stands for common business oriented language. (b) a significant percentage of business software is still programmed in it. (c) it was developed in 1992. (d) COBOL is used for commercial applications that require precise and efficient manipulation of large amounts of data.

(c)

1.14 The World Wide Web (a) was developed at roughly the same time as the Internet (b) paved the way for the Internet (c) was developed years after the Internet (d) was designed for "stand-alone" computers

(c)

1.2 Computers: Hardware and Software 1.3 Today's fastest computers are called __________. (a) mega computers (b) terminals (c) supercomputers (d) CPUs

(c)

1.27 Which popular language was developed by IBM Corporation to be used for scientific and engineering applications that require complex mathematical computations? (a) Smalltalk (b) Pascal (c) FORTRAN (d) COBOL

(c)

1.7 History of C 1.19 Which of the following languages was an ancestor of C? (a) A (b) A+ (c) B (d) B+

(c)

1.7 The central processing unit (CPU) __________. (a) retains information so that the information can be readily available for processing. (b) performs calculations such as addition, subtraction, multiplication, and division. (c) supervises the operation of the other sections. (d) obtains information from input devices and places it at the disposal of other units.

(c)

1.8 Programs or data not actively being used by the other units are placed on the __________. (a) output unit. (b) memory unit. (c) secondary storage unit. (d) central processing unit.

(c)

2.10. Which of the following is not a synonym for a C string? a) message b) character string c) character d) literal

(c)

2.11. The following line is most properly an example of a __________. printf( "Welcome to C!" ); a) function b) block c) statement d) header

(c)

2.16 Which of the following is an invalid identifier (variable name)? (a) _Test (b) TEST (c) 5test (d) test1

(c)

2.19. A(n) __________ is a location in the computer's memory where a value can be stored for use by a program. a) unknown b) name c) variable d) declaration

(c)

2.22. Which of the following statements is false? a) C is case sensitive. b) Uppercase and lowercase letters are different in C. c) identifier and IdEnTiFiEr are identical identifiers in C. d) Identifiers can be of any length

(c)

2.23. Which of the following multiple word variable names does not conform to the good programming practices in the text? a) multiple_word_variable_name b) multipleWordVariableName c) multiplewordvariablename d) aReallyReallyLongMultipleWordVa

(c)

2.26. Which statement is false? a) in the statement sum = integer1 + integer2; both = and + are binary operators. b) The statement in part a) is an example of an assignment statement. c) The spaces around each of the binary operators in the statement of part a) are required. d) In part a), the = operator's two operands are sum and the value of the expression integer1 + integer2.

(c)

2.27. Which of the following is false? a) Each variable being input in a scanf statement is generally preceded by an &. b) Each variable being output in a printf statement is generally not preceded by an &. c) In a printf statement, the comma that separates the format control string from the expressions to be printed is placed inside the format control string. d) Calculations can be performed inside printf statements.

(c)

2.30. Every variable has all the attributes below, except a) name b) value c) alias d) type

(c)

2.4 Which of the following is not a valid escape sequence? (a) \n (b) \\ (c) \~ (d) \"

(c)

2.44. Which statement is false? a) It is not correct to split an identifier with a space, a tab or a newline. b) Statements and comments may be split over several lines. c) The equals sign (=) is not an operator. d) A good programming practice is to break a line after a comma in a lengthy comma-separated list.

(c)

2.48. Which is not a keyword? a) register b) volatile c) external d) struct

(c)

2.6. Lines beginning with a # are processed a) at execution time b) at compile time c) at preprocessor time d) at postprocessor time

(c)

3.1 Introduction 3.2 Algorithms 3.1 Specifying the order in which statements are to be executed in a computer program is called (a) an algorithm (b) transfer of control (c) program control (d) pseudocode

(c)

3.12. Various C statements enable the programmer to specify that the next statement to be executed may be other than the next one in sequence. This is called __________. a) change of order b) instruction skipping c) transfer of control d) rerouting

(c)

3.17. Small circle symbols in a flowchart are often called __________ symbols. a) little circle b) collision c) connector d) collator

(c)

3.2. The two key attributes of an algorithm are: a) actions and start activity b) flow and order of flow c) actions and order of actions d) flow and start activity

(c)

3.4 Control Structures 3.7 Which of the following encompasses the other three? (a) sequence structure (b) repetition structure (c) control structure (d) selection structure

(c)

3.5. Which statement is false? a) Pseudocode is an artificial and informal language that helps programmers develop algorithms. b) Pseudocode is similar to everyday English. c) Pseudocode is an actual programming language. d) Pseudocode programs are not actually executed on computers.

(c)

3.6. Which statement is false? a) Pseudocode helps the programmer "think out" a program before attempting to write it in a programming language such as C. b) Pseudocode programs consist purely of characters so programmers may conveniently type pseudocode programs into a computer using an editor program. c) A carefully prepared pseudocode program is only a beginning; it still takes a tremendous amount of work to convert a pseudocode program into a C program. d) Pseudocode consists only of action statements.

(c)

3.8 In a flowchart of an algorithm, what is the shape of the decision symbol? (a) circle (b) rectangle (c) diamond (d) oval

(c)

3.9 Which of the following is a repetition structure? (a) if (b) if...else (c) do...while (d) switch

(c)

1.13 Key Software Trend: Object Technology 1.29 Which of the following is not an advantage of object-oriented programming? (a) software is more reusable (b) software is more understandable and easier to maintain (c) programmers are able to model the real world (d) all of the above are advantages of object-oriented programming

(d)

1.21 Using standard library functions can be more efficient because __________. (a) they save programming time (b) they are carefully written to perform optimally (c) they increase program portability (d) all of the above.

(d)

1.33 The invention of the __________ in the late 1970s and 1980s laid the groundwork for the productivity improvements of the 1990s. (a) transistor (b) c (c) inexpensive hardware (d) microprocessor chip

(d)

1.8 C Standard Library 1.20 When programming in C you will typically use all of the following building blocks except __________. (a) functions from the standard library (b) functions you create yourself (c) functions other people have created for you (d) functions provided by ANSI / ISO

(d)

2.13. A linked program is often called a(n) __________. a) chain b) library c) object d) executable

(d)

2.21. Which of these is not a valid identifier? a) a_valid_identifier b) a1_valid_identifier c) a_valid_identifier_ d) 1_valid_identifier

(d)

2.25. The address operator is a) && b) % c) @ d) &

(d)

2.3 Another Simple Program: Adding Two Integers 2.15 Which of the following is not a valid integer value? (a) -3 (b) 0 (c) 2134859 (d) 1.1

(d)

2.36. a * (b + c) may also be written in C as a) ab + ac b) (a * b ) + c c) a * b + c d) a * b + a * c

(d)

2.41. Which statement is false? a) Executable C statements either perform actions or make decisions. b) If the condition in an if statement is met, the statement in the body of the if statement is executed. c) All the relational operators have the same level of precedence. d) The equality operators have a higher level of precedence than the relational operators.

(d)

2.45. Which of the following is not a keyword? a) int b) return c) if d) main

(d)

2.47. The order in which statements are __________ is called flow of control. a) entered in a source file b) preprocessed c) compiled d) executed

(d)

2.5. Which statement about comments is false? a) Comments begin and end with /* and */, respectively. b) Programmers insert comments to document programs and improve program readability. c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

(d)

2.8. In the line int main() the parentheses indicate that main is a program building block called a a) module b) statement c) directive d) function

(d)

3.11. Normally, statements in a program are eexecuted one after the other in the order in which they are written. This is called __________ execution. a) inline b) seeking c) ordered d) sequential

(d)

3.15. The __________ flowchart symbol is also called the action symbol. a) small circle b) diamond c) oval d) rectangle

(d)

3.18. The diamond flowcharting symbol is also called the __________ symbol. a) determination b) derision c) declarative d) decision

(d)


संबंधित स्टडी सेट्स

NU271 PrepU: Reproduction (week 9)

View Set

YouTube Channel Growth Certification - Course 7

View Set

Bio Ch. 7: The Cardiovascular System

View Set

Chapters 14 - 16, Geography Test

View Set

chapter 7 the discovery of cells

View Set