final

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

he condition num != 65 cannot be replaced by:

!(num - 65)

The special conversion specifier for printing addresses is______________

%p

Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array?

&t[ 3 ]

Pointers cannot 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) reference values directly.

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) *Ptr

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) int * a

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) variables defined with the storage class static

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

(d) both (b) and (c)

Which of the following is not a whitespace character? - '\n'- '\f'- '\r'- '\w'

- '\w'

What is the output of the following statement?printf( "%s", strspn( "Cows like to moo.", "Ceiklosw " ); - Nothing .- 10 - 8 - e

- 10

The number 4 typically takes up _________ bit(s) when stored as a character on most of today's computers. - 1 - 2 - 3 - 8

- 8

Which statement is false? - Function strcpy copies its first argument into its second argument. - Function strncpy does not necessarily copy the terminating null character of its second argument. - A common error is not appending a terminating null character to the first argument of a strncpy when the third argument is less than or equal to the length of the string in the second argument. - The first character of the second argument of strcat replaces the null character that terminates the string in the first argument.

- Function strcpy copies its first argument into its second argument.

Which statement is false? - Function strerror takes an error number and creates an error message string. - Function strerror maps its integer argument into a full text string in a system-dependent manner - Function strlen determines the length of a string including the null character. - Function strerror does not display its string output.

- Function strlen determines the length of a string including the null character.

Which of the following is false? - A string may include letters, digits, and various special characters (i.e., +, -, *). - A string in C is an array of characters ending in the null character ('\0'). - String literals are written inside of single quotes - A string may be assigned in a definition to either a character array or a variable of type char *.

- String literals are written inside of single quotes

Which statement about the memory functions of the string handling library is false? - The functions treat blocks of memory as strings. - The functions facilitate manipulating, comparing and searching blocks of memory. - The pointer parameters to these functions are defined void *. - A void * pointer cannot be dereferenced.

- The functions treat blocks of memory as strings.

Which statement about strtok is false? - It breaks a string into tokens. - Subsequent calls to continue tokenizing the same string contain NULL as the first argument. - The length of the current token is returned by each call. - If there are no more tokens when the function is called, NULL is returned.

- The length of the current token is returned by each call.

Which statement is false? - Function atof returns a double version of its argument. - If the converted value cannot be represented, the behavior of atoi is undefined .- When using functions from the general utilities library, its header file must be included. - Function strtol receives three arguments.

- When using functions from the general utilities library, its header file must be included.

Function strcspn returns __________. - a length - a range of characters - the starting and ending positions of a range of characters - a char

- a length

A string in C is __________. - an array of characters ending in the empty string - a sequence of characters contained within single quotes - a sequence of characters preceded by a length field - an array of characters ending in the null character

- an array of characters ending in the null character

ASCII and EBCDIC are - characters - strings - character sets - character comparison operators

- character sets

The isxdigit (is hex digit) function would return false on - a - A - 2 - g

- g

Function __________ inputs the next character from the standard input and returns it as an integer. - inputchr - getchr - inputchar - getchar

- getchar

The strtol and stroulfunctions do not - need a special header file in order to be used. - take three arguments. - have to convert the entire string they are given. - have the ability to output data in base 8.

- have to convert the entire string they are given.

__________ values can consist of the digits 0 through 9 and the letters A through F. - hexadecimal - binary - octal - decimal

- hexadecimal

Which is not a capability of the string-handling library? - tokenizing strings - comparing strings - searching strings - inputting strings

- inputting strings

A character constant is a(n) __________ value represented as a character in single quotes. - short - int - long - double

- int

The functions of the character-handling library typically manipulate characters as ___________. - ints. - floats. - longs. - bits.

- ints.

The ___________ function allows characters of one part of a string to be copied into another part of the string. - memchr - memcmp - memset - memmove

- memmove

To change the string "ABCDEFGHI" to "aaaaaFGHI" you would use the _________ function. - memset- memcmp- memchr- memcopy

- memset

What memory function of the string handling library copies an unsigned char into a specified number of the leading locations pointed to by its first argument? - memcpy - memmove - memset - memlead

- memset

'\n' represents the integer value of - the character n - the string n - newline - nextline

- newline

The integral type of the value returned by operator sizeof is __________. - size-t - sizet - size.t - size_t

- size_t

+, \ and $ are all examples of __________. - special characters - strings - operators - literals

- special characters

Which statement is true? - sprintf takes its input from a character array. - sprintf prints its output in string format on the screen. - sprintf stores its output in a character array. - sprintf is a secure version of printf.

- sprintf stores its output in a character array.

Function __________ searches for the first occurrence of a character in a string. - firstchar - getfirst - firstchr - strchr

- strchr

Function __________ takes an error number and creates an error message string. - errorstr - strerror - badstr - strfail

- strerror

Assuming that string1 = "hello" and string2 = "hello world", Which of the following returns 0? - strcmp(string1, string2); - strcmp(string1, string2, 6); - strncmp(string1, string2, 6); - strncmp(string1, string2, 5);

- strncmp(string1, string2, 5);

Every function of the string handling library except for __________ appends the null character to its result. - strncpy - strncat - strcpy - strcat

- strncpy

Which function would be the most useful for determining if a certain word is contained in a string representing a sentence? - strcspn - strchr - strstr - strrchr

- strstr

Which statement is true? - strtok modifies the input string. - strtok makes a backup copy of the input string. - The first argument of each call to strtok is the string being tokenized. - strtok works only with a set of four predefined delimiters.

- strtok modifies the input string.

Function fgetsappends a __________ to its array target in memory. - leading null character - leading end-of-file character - terminating null character - terminating end-of-file character

- terminating null character

The strlen function returns ________. - the number of characters in a string excluding the null character - the number of characters in a string including the null character - the ASCII representation of the character - none of these

- the number of characters in a string excluding the null character

strtok does not - replace each delimiting character with '\0' - return a pointer to the token it creates - tokenize the entire a string when it's called - modify the input string

- tokenize the entire a string when it's called

Which character-handling library function converts lowercase letters to uppercase letters? - lowertoupper - isupper - touppercase - toupper

- toupper

memcmp would return ___________ for the callmemcmp("Hi, how are you?", "Hi, how are things?", 6); - -1 - a negative number. - zero. - a positive number.

- zero.

The first element in every array is the ________ element.

0

Which of the following is not a valid integer value?

1.1

A sorted array of a million elements can be searched by a binary search in_________ or fewer comparisons.

20

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?

2012

Given the following definitions, what is thevalue of b[1][0]?int b[2][2] = {{1}, {3, 4}};

3

An array containing 3 columns and 4 rows is typically referred to as a __________.

4-by-3 array

Assuming the following pseudocode for the Fibonacci series, what is the value of fibonacci(5)? fibonacci(0) = 0 fibonacci(1) = 1 fibonacci(n) = fibonacci(n - 1) + fibonacci(n - 2)

5

Which statement about C arithmetic is false?

5 / 2 yields 2.5

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?

6

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)

77

A bubble sort of 1000 elements requires a maximum of _______ passes.

999

The empty statement is represented by placing __________ where a statement would normally be.

;

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?

<=

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.

<stdlib.h>

Which of the following is an equality operator?

==

An operator that associates from right to left is:

?:

Which statement is false about multidimensional arrays?

A common use of multidimensional arrays is to arrange data into tables consisting of rows and columns.

To follow the principle of least privilege, the selectionSort function should receive the array to be sorted as:

A constant pointer to non constant data.

Which of the following statements is true? A counter variable that stores only non-negative numbers should be declared as an unsigned integral type. A counter variables that stores only non-negative numbers should be declared as a signed integral type. The type of a counter does not matter None of the above.

A counter variable that stores only non-negative numbers should be declared as an unsigned integral type.

A pointer can not be assigned to: Another pointer of the same type without using the cast operator. A pointer to void without using the cast operator. Any other pointer by using the case operator. A pointer of a type other than its own type and void without using the cast operator.

A pointer of a type other than its own type and void without using the cast operator.

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

A static local variable is visible only in the control structure in which it is defined

Which of the following can have a pointer as an operand? A) ++ B) *= C) % D) /

A) ++

Which of the following statements is false? A) A key feature of functions like printf_s and scanf_s that makes them more secure is that they have runtime pointer constraints that are checked after attempting to use the pointers B) In a scanf_s, if any of the pointer arguments (including the format-control string) are NULL, the function returns EOF. C) In a printf_s, if the format-control string or any argument that corresponds to a %s is NULL, the function stops outputting data and returns a negative number. D) None of the above.

A) A key feature of functions like printf_s and scanf_s that makes them more secure is that they have runtime pointer constraints that are checked after attempting to use the pointers

Which of the following statements is false? A) C provides automatic bounds checking for arrays. B) C provides no automatic bounds checking for arrays, so you must provide your own. C) Allowing programs to read from or write to array elements outside the bounds of arrays are common security flaws. D) Writing to an out-of-bounds element (known as a buffer overflow) can corrupt a program's data in memory, crash a program and allow attackers to exploit the system and execute their own code.

A) C provides automatic bounds checking for arrays.

Which statement is false? A) Function strcpy copies its first argument into its second argument. B) Function strncpy does not necessarily copy the terminating null character of its second argument. C) A common error is not appending a terminating null character to the first argument of a strncpy when the third argument is less than or equal to the length of the string in the second argument. D) The first character of the second argument of strcat replaces the null character that terminates the string in the first argument.

A) Function strcpy copies its first argument into its second argument

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) The brackets used to enclose the subscript of an array are not an operator in C.

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) This statement increases the appropriate frequency counter depending on the value of responses[answer].

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) can result in changes to the value of an unrelated variable

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) int n[5] = {0, 7, 0, 3, 8, 2};

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) it knows the size of the array it was passed

Which statement is true? A) strtok modifies the input string. B) strtok makes a backup copy of the input string. C) The first argument of each call to strtok is the string being tokenized. D) strtok works only with a set of four predefined delimiters.

A) strtok modifies the input string.

Three of the follow expressions have the same value. Which of the following expressions has a value different from the others'? A)*ptr B)&*ptr C)ptr D)*&ptr

A)*ptr

An ancestor of today's Internet was _____________.

ARPAnet

Which of the following statements is true? a.The C standard library does not provide a secure random-number generator. b.According to the C standard document's description of function rand, "There are no guarantees as to the quality of the random sequence produced and some implementations are known to produce sequences with distressingly non-random low-order bits." c.The CERT guideline MSC30-C indicates that implementation-specific random-number generation functions must be used to ensure that the random numbers produced are not predictable d.All of the above.

All of the above.

What happens if the loop-continuation test is omitted in a for-statement?

An infinite loop.

The three types of computer programming languages discussed in the chapter are machine languages, __________ and __________.

Assembly languages, and High-Level languages

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)

B) A Static Local Variable is visible only in the control structure in which it is defined.

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) It is a high-performance sort.

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) The indirection operator * distributes to all comma-separated variable names in a definition.

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) call-by-reference, call-by-value

Pointers cannot 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) reference values directly.

Function _________ takes an error number and creates and error message string. A) errorstr B) strerror C) badstr D) strfail

B) strerror

Which of the following does not necessarily append the null character to its result? A) strcpy B) strncpy C) strcat D) strncat

B) strncpy

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. the array must be passed call-by-reference.

B) the array parameter can be preceded by the const qualifier.

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)Entire arrays are passed simulated call by reference and individual array elements are normally passed call by value.

Which of these is generally thought of as a high-performance technique?

Binary search

C++ was developed by

Bjarne Stroustrup

The unary * and __________ are complements of one another. A) / B) ^ C) & D) |

C) &

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) 11

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) The address operator can be applied to variables defined with the storage class register.

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) can be used to specify array sizes, thereby making programs more scalable

What memory function of the string handling library copies an unsigned char into a specified number of the leading locations pointed by its first argument? A) memcpy B) memmove C) memset D) memlead

C) memset

strtok does not A) replace each delimiting character with '\0' B) return a pointer to the token it creates C) tokenize the entire a string when it's called D) modify the input string

C) tokenize the entire string when it's called

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) variables defined with the storage class static

The special conversion specifier for printing addresses is __________. A) %a B) %m C)%p D) %loc

C)%p

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

Call by value should be used whenever the called function does not need to modify the value of the caller's original value.

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

Comma operators evaluate lists of expressions from right to left.

A string array is commonly used for:

Command-line arguments.

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) 4-by-3 array

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 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.

D) A constant pointer to constant data.

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) It is initializing successive elements of an array.

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) When using scanf, you must always precede with the & operator the name of each variable into which inputs are being placed.

An array is not ________. A) a consecutive group of memory locations B) indexed by integers C) pointer-based D) a dynamic entity

D) a dynamic entity

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) char string1[] = {'f', 'i', 'r', 's', 't', '\0'};

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) int c[12];

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) is a correct definition of integer pointer count.

The integral type of the value returned by operator sizeof is ________. A) size-t B) sizet C) size.t D) size_t

D) size_t

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) the address of the function in memory

All of the following can cause a fatal execution-time error except: Dereferencing a variable that is not a pointer. Dereferencing a variable that has not been assigned to point to a specific address. Dereferencing a pointer that has not been initialized properly. Dereferencing a null pointer.

Dereferencing a variable that is not a pointer.

Lists, queues, stacks and trees are _________ data structures that may grow and shrink as programs execute.

Dynamic

Which statement is true? Entire arrays are passed simulated call by reference and individual array elements are normally passed simulated call by reference. Entire arrays are passed simulated call by reference and individual array elements are normally passed call by value. Entire arrays are passed call by value and individual array elements are normally passed simulated call by reference. Entire arrays are passed call by value and individual array elements are normally passed call by value.

Entire arrays are passed simulated call by reference and individual array elements are normally passed call by value.

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

Every function should be broken into smaller functions.

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

In C, we write ab to multiply a times b.

Which of the following is false?

In a printf statement, the comma that separates the format con-trol string from the expressions to be printed is placed inside the format control string.

( *max )( num1, num2, num3 ); :

Is a call to the function pointed to by max.

Which statement about the algorithm we presented in Section 7.10 of the text for shuffling a deck of cards is true?

It could execute indefinitely

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

It is not incorrect to use the same names for the arguments passed to a function and the corresponding parameters in the function definition.

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

Lengthy comments can cause poor execution-time performance.

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

Monetary calculations can be performed in C.

Which of the following is not an advantage of object-oriented programming? Software is more reusable. Software is more understandable, correct and modify. Using a modular, object-oriented design-and-implementation approach can make software-evelopment groups much more productive. None of the above—these are all advantages of object-oriented programming.

None of the above—these are all advantages of object-oriented programming.

___ models software in terms similar to those that people use to describe real-world objects.

Object-oriented design

If grade has the value of 60 what will the following code print? if (grade >= 60) { puts("Passed");}

Passed

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

Reading a value out of a memory location destroys that value.

___ involves reworking programs to make them clearer and easier to maintain while preserving their correctness and functionality

Refactoring

Pointers cannot be used to:

Reference values directly.

Which software product release category is "generally feature complete and supposedly bug free, and ready for use by the community?" Alpha. Beta. Release candidate. Continuous beta.

Release candidate.

Which statement is false?

Structures are always passed call by reference.

An algorithm that could execute for an unknown amount of time because it depends on random numbers to exit a function may

Suffer from indefinite postponement.

Java was developed by ___________.

Sun Microsystems

Which statement is false? The assignment operator associates from left to right. The arithmetic operators associate from left to right. The equality operators associate from left to right. The relational operators associate from left to righ

The assignment operator associates from left to right

Which statement is false? The compiler uses function prototypes to validate function calls. Prior to ANSI C, C did not include function prototypes. 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. The designers of ANSI C++ borrowed the notion of function prototypes from the developers of C.

The designers of ANSI C++ borrowed the notion of function prototypes from the developers of C.

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

The expression y = a * x * x + b * x + c does exponentiation without an exponentiation operator.

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

The increment must be greater than zero.

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

The logical AND of two expressions is true if and only if each of the conditions is true.

Which statement is false? A recursive function is a function that calls itself either directly or indirectly through another function. A recursive function knows how to solve only one or more base cases. The recursion step executes after the original call to the function terminates. 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.

The recursion step executes after the original call to the function terminates.

Which statement about function memcpy is false?

The result of this function is defined even if the two objects overlap in memory.

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

The sequence structure is essentially built into C.

After the ith iteration of the selection sort:

The smallest i items of the array will be sorted into increasing order in the first i elements of the array.

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

The spaces around each of the binary operators in the statement of part a) are required.

Comparing pointers and performing pointer arithmetic on them is meaningless unless:

They point to elements of the same array.

Which of the following is not true of static local variables?

They're accessible outside of the function in which they are defined

Which of the following will not produce a syntax error?

Using the same names for arguments passed to a function and the corresponding parameters in the function definition

Which statement is false. Variables may be defined anywhere in the body of main. All variables must be defined before they are used. All variable definitions must include the name and data type of each variable. Several variables of the same data type may be defined in one definition.

Variables may be defined anywhere in the body of main.

Which statement is false?

When applied to the name of an array, sizeof returns the number of elements in the array.

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

When using scanf, you must always precede with the & operator the name of each variable into which inputs are being placed.

What is wrong with the following loop? While (sum <= 1000) { sum = sum + 30;}

While should be while.

Which of the following statements is false? The concepts of icons, menus and windows were originally developed by Xer-ox PARC. Windows is an open source operating system. The software that contains the core components of the operating system is called the kernel. Linux source code is available to the public for examination and modification.

Windows is an open source operating system.

The escape sequence for horizontal tab is

\t

Which of the following is not a valid escape sequence?

\~

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

a) &

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

a) &arrayName[0]

Which statement is false? a) It's 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 receivesa pointer and a function that receives a single-subscripted array. d) The function must "know" whether it is receiving a single-sub-scripted array or simply a single variable for which it is to perform simulated call by reference.

a) It's necessary to include names of pointer arguments in function prototypes.

A two-dimensional array element incorrectly referenced as a[x, y] is actually evaluated as

a[y]

An identifier's storage class determines the period during which that identifier exists in memory 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 determines where the identifier can be referenced in a program all of the above

all of the above

The linker creates __________.

an executable image

A programmer intentionally creates a for-loop with the following for header: for (; ;)

an infinite loop

What is produced by a for statement with a correct body and with the following header for (i = 20; i >= 2; i += 2)

an infinite loop

How many times will the following program print hello? i = 1;while (i <= 10) { puts("hello");}

an infinite number of times

Which is not a storage class? automatic register extern static

automatic

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) The indirection operator * distributes to all comma-separated variable names in a definition.

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) addresses

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) assigns the address of the variable yPtr to pointer variable y.

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) directly, indirectly

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

b) indirection

Which initialization is not performed by the following definition?int b[2][2] = {{1},{3,4}};

b[0[1] is set to 1

The smallest data item in a computer, called a ________, can assume the value 0 or the value 1.

bit

If the loop-continuation condition in a for statement is initially false, ________. the body portion of the loop is not performed execution proceeds with the statement following the for statement both a and b none of the above

both a and b

Which of the following will not increment variable c by one?

c + 1;

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

c) Call-by-value is always more efficient than call-by-reference

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) The address operator can be applied to variables defined with the storage class register.

Which statement is false? a) The unary * operator is called the indirection operator or the deref-erencing 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) The unary operator returns the value of its operand.

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

c) memory addresses

The binary search technique

can only be used on a sorted array

The following array definitionint n[5] = {32, 27, 64, 18, 95, 14};

causes a logic a syntax error because there are six initializer but only five array elements.

the definition char string1[]="first"; is equivalent to:

char string1[]={'f', 'i', 'r', 's', 't','\0'};

Which of the following is not a synonym for a C string?

character

cin.getline( superstring, 30 ); is equivalent to which of the following?

cin.getline( superstring, 30, '\n' );

Which of the following encompasses the other three?

control structure

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 im-portant data. d) Derefencing an uninitialized pointer causes a syntax error.

d) Derefencing an uninitialized pointer causes a syntax error

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) The values 0 and 1 are the only values that can be assigned directly to a pointer variable.

When the __________ of a variable is passed to a function, the indi-rection 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) address, value

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) is a correct definition of integer pointer count.

The diamond flowcharting symbol is also called the __________ symbol.

decision

The function prototype double mySqrt(int x);

defines a function called mySqrt which takes an integer as an argument and returns a double

Counter-controlled iteration is often called __________ iteration because the number of iterations is known before the loop begins executing.

definite

Which is not a C iteration statement?

do...for

A linked program is often called a(n)

executable

The order in which statements are __________ is called flow of control.

executed

Which is not an attribute of a variable?

external class

Which data type should normally not be used to control a counting loop?

float

The comma operator is most often used in __________ statements.

for

When programming in C you'll typically use all of the following building blocks except _ functions from the standard library functions you create yourself functions other people have created for you functions provided by ANSI / ISO

functions provided by ANSI / ISO

The strtol and stroul functions do not ________.

have to convert the entire string they are given.

The __________ selection statement performs an action if a condition is true and skips that action if the condition is false.

if

The __________ is called a double selection statement.

if ...else

What is bandwidth?

information carrying capacity

If there are fewer initializers than elements in the array, the remaining elements are ___________.

initialized to zero

A character constant is a(n) _______ value represented as a character in single quotes?

int

Which of the following does not initialize all of the array elements of 0?

int b[2][2]; for (int I= 0; I <2; ++I){ for (int j = 0; j < 2;++j){ b[I][j] = 0 } }

Which definition tells the computer to reserve 12 elements for integer array c?

int c[12];

Which of the following is not a correct way to initialize an array?

int n[5] = {0, 7, 0, 3, 8, 2};

Programs that directly execute high-level language programs without compiling are called __________.

interpreterS

The functions of the character handling library typically manipulates characters as _______?

ints.

Which character handling library function returns true it its argument is a printing character?

isprint

Suppose a program contains the code ( = 1; I <= 10; I++){ n[I] = 0 } which statement about this code must be true?

it is initializing successive elements of an array.

Variable names actually correspond to

locations in the computer's memory

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.

logic, syntax

Non-constant variables are also known as

lvalues, but can be used as rvalues

The & operator can be applied to:

lvalues.

Which of the following must every C program have?

main

the____ is the average value of a set of data items.

mean

In order to calculate the ___________ of an array the array must be sorted.

median

The ________ function allows characters of one part of a string to be copied into another part of the string.

memmove

In a switch statement a break is required after each case multiple actions do not need to be enclosed in braces a default case is required a break is required after the default case

multiple actions do not need to be enclosed in braces

A function that prints a string should have a parameter that's a

nonconstant pointer to constant data

When the computer compares two strings, it actually compares the ________ in the strings.

numeric code of the characters

Which of the following is going to be the key programming methodology for the next decade? object-oriented programming structured programming "legacy C code" "live-code approach"

object-oriented programming

___ are essentially reusable software components that model items in the real world. objects supersets modules developers

objects

The program segment int counter = 1;do { printf("%i ", counter);} while (++counter <= 10); will ________.

print the numbers 1 through 10

Which of the following statements should be used in secure C programming to display the string "Welcome" not followed by a new-line character?

printf( "%s", "Welcome" );

Which of the following is not one of the six logical units of a computer? input unit programmer unit memory unit output unit

programmer unit

int square(int); is an example of a function

prototype

When arguments are passed by __________, the caller allows the called function to modify the original variable's value.

reference

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 _________________.

reference, value

When a called function completes its task, it normally

returns to the calling function

An array is a group of memory locations related by the fact that they all have _________ array name and ______________type.

same, same

Assuming myString is a 20-element char array, which of the following statements might result in buffer overflow?

scanf("%s", myString);

Indefinite iteration is controlled by a

sentinel value

Normally, statements in a program are executed one after the other in the order in which they are written. This is called __________ execution.

sequential

In indefinite iteration, an input value

should always be evaluated before being processed

Which of the following statements is true? software commands the computer to perform actions and make decisions Answers: hardware controls software software commands the computer to perform actions and make decisions C is an object oriented programming language software commands the computer to perform actions and make decisions and C is an object oriented programming language

software commands the computer to perform actions and make decisions

Function strcmp returns ______ if its first argument is equal to its second argument.

specifically 0

Function strcmp returns __________ if its first argument is equal to its second argument. - specifically 1 - any non-zero value (i.e., true) - specifically 0 - any negative value

specifically 0

Which function does not read data from standard input?

sprintf

Arrays and structures are ____________ entities in that they remain the same size throughout program execution

static

The general utilities library is

stdlib

The OR (||) operator

stops evaluation upon finding one condition to be true

Function _______ searches for the first occurrence of a character in a string.

strchr

Assume string1 is a character array. Which of the following operations does not produce a string?

string1[]={'t', 'e', 's', 't'};

Function ________ compares up to n characters of its first argument with its second argument.

strncmp

Assuming that string1 = "Hello" and string2 = "Hello World", Which of the following returns 0?

strncmp(string1, string2, 5);

The __________ selection statement performs one of many different actions, depending on the value of an expression.

switch

Placing a semicolon after the right parenthesis enclosing the parameter list of a function definition is a __________ error.

syntax

The compile stage is when ____________.

the C program is translated into machine language code

To prevent modification of array values in a function,

the array parameter can be preceded by the const qualifier.

To pass an array to a function, specify

the name of the array without any brackets

When a number gets assigned to a variable that already has a value __________.

the new number overwrites the previous value at that memory location

what is wrong with this code?int[]=(1,2,3,4,5);

the parentheses should be curly braces.

An uninitialized variable contains ________.

the value last stored in the memory location reserved for that variable

Which of the following is true of pseudocode programs?

they help the programmer "think out" a program

The only identifiers that can be reused elsewhere in a program without any ambiguity are

those in the parameter list of a function prototype

Arrays are data structures consisting of related data items of the same _____________.

type

Which one item is most different from the other three?

worker function


Kaugnay na mga set ng pag-aaral

Are You Mastering Audience Engagement? A Fun Quiz to Find Out!

View Set

EMT - Prehospital Emergency Care: Part 6: Assessment: Chapter 13: Patient Assessment

View Set

Chapter 7: Connect Master Intro to Business

View Set

module 2: chapter 3 and 4 retail accounting

View Set

Song Lyrics - The Beatles - Hey Jude

View Set

3: Macro Environmental Analysis and Scenario Planning

View Set

History of Rock and Roll Chapters 10-15

View Set