Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Computer Science
Q:
Function __________ searches for the first occurrence in its first string argument of any character in its second string argument.
a) strfirst
b) strstr
c) firstany
d) strpbrk
Q:
Function strcspn returns __________.
a) a length
b) a range of characters
c) the starting and ending positions of a range of characters
d) a char
Q:
Function __________ searches for the first occurrence of a character in a string.
a) firstchar
b) getfirst
c) firstchr
d) strchr
Q:
What is the output of the following statement?
printf( "%s", strspn( "Cows like to moo.", "Ceiklosw " );
(a) Nothing.
(b) 10
(c) 8
(d) e
Q:
Which function would be the most useful for determining if a certain word is contained in a string representing a sentence?
(a) strcspn
(b) strchr
(c) strstr
(d) strrchr
Q:
Q:
When the computer compares two strings, it actually compares the __________ in the strings.
a) number of characters
b) numeric codes of the characters
c) character bits
d) lengths of the leading alphabetic portions
Q:
ASCII and EBCDIC are
a) characters
b) strings
c) character sets
d) character comparison operators
Q:
Function __________ compares up to n characters of its first argument with its second argument.
a) nstrcmp
b) strncmp
c) strcmpn
d) strcmp
Q:
Function strcmp returns __________ if its first argument is equal to its second argument.
a) specifically 1
b) any non-zero value (i.e., true)
c) specifically 0
d) any negative value
Q:
Assuming that string1 = "hello" and string2 = "hello world", Which of the following returns 0?
(a) strcmp(string1, string2);
(b) strcmp(string1, string2, 6);
(c) strncmp(string1, string2, 6);
(d) strncmp(string1, string2, 5);
Q:
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.
Q:
The integral type of the value returned by operator sizeof is __________.
a) size-t
b) sizet
c) size.t
d) size_t
Q:
Every function of the string handling library except for __________ appends the null character to its result.
a) strncpy
b) strncat
c) strcpy
d) strcat
Q:
Which is not a capability of the string-handling library?
a) tokenizing strings
b) comparing strings
c) searching strings
d) inputting strings
Q:
Which of the following does not necessarily append the null character to its result?
(a) strcpy
(b) strncpy
(c) strcat
(d) strncat
Q:
Which statement is true?
a) sprintf takes its input from a character array.
b) sprintf prints its output in string format on the screen.
c) sprintf stores its output in a character array.
d) sprintf is a secure version of printf.
Q:
Function fgets appends a __________ to its array target in memory.
a) leading null character
b) leading end-of-file character
c) terminating null character
d) terminating end-of-file character
Q:
Function __________ prints the character equivalent of its integer argument.
a) putchar
b) putch
c) printchar
d) printch
Q:
Function __________ inputs the next character from the standard input and returns it as an integer.
a) inputchr
b) getchr
c) inputchar
d) getchar
Q:
Which function does not read data from standard input?
(a) scanf
(b) sscanf
(c) sprintf
(d) getchar
Q:
__________ values can consist of the digits 0 through 9 and the letters A through F.
a) hexadecimal
b) binary
c) octal
d) decimal
Q:
Which statement is false?
a) Function atof returns a double version of its argument.
b) If the converted value cannot be represented, the behavior of atoi is undefined.
c) When using functions from the general utilities library, its header file must be included.
d) Function strtol receives three arguments.
Q:
The general utilities library is
a) stdutil
b) stdlibrary
c) stdutility
d) stdlib
Q:
The strtol and stroul functions do not
(a) need a special header file in order to be used.
(b) take three arguments.
(c) have to convert the entire string they are given.
(d) have the ability to output data in base 8.
Q:
Which character handling library function returns true if its argument is a printing character?
a) ispchar
b) isprintablechar
c) isprint
d) isprintchar
Q:
Q:
Which character-handling library function converts lowercase letters to uppercase letters?
a) lowertoupper
b) isupper
c) touppercase
d) toupper
Q:
Which character-handling library function returns a true value if its argument is a letter and 0 otherwise?
a) isalphanumeric
b) isalphabetic
c) isalpha
d) isletter
Q:
The isxdigit (is hex digit) function would return false on
(a) a
(b) A
(c) 2
(d) g
Q:
The functions of the character-handling library typically manipulate characters as ___________.
(a) ints.
(b) floats.
(c) longs.
(d) bits.
Q:
The number 4 typically takes up _________ bit(s) when stored as a character on most of today's computers.
(a) 1
(b) 2
(c) 3
(d) 8
Q:
In C, it is appropriate to say that a string is a(n) __________.
a) pointer
b) integer
c) double quote
d) sequence of characters contained in single quotes
Q:
A string in C is __________.
a) an array of characters ending in the empty string
b) a sequence of characters contained within single quotes
c) a sequence of characters preceded by a length field
d) an array of characters ending in the null character
Q:
Q:
'
' represents the integer value of
a) the character n
b) the string n
c) newline
d) nextline
Q:
A character constant is a(n) __________ value represented as a character in single quotes.
a) short
b) int
c) long
d) double
Q:
Q:
Which of the following statements is false?
(a) Dereferencing NULL pointers typically causes programs to crash.
(b) If a function parameter points to a value that will not be changed by the function, const should be used to indicate that the data is constant.
(c) Attackers cannot execute code by dereferencing a NULL pointer.
(d)None of the above.
Q:
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.
Q:
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)
Q:
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
Q:
(*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
Q:
Which of the following is false with regard to pointers to functions?
(a) They contain the starting address of the function code.
(b) They"re dereferenced in order to call the function.
(c) They can be stored in arrays.
(d) They cannot be assigned to other function pointers
Q:
Which statement about the algorithm we presented in Section 7. of the text for shuffling a deck of cards is true?
a) It's guaranteed to terminate.
b) It could execute indefinitely.
c) It's efficient.
d) It uses a one-dimensional array of 52 cards.
Q:
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.
Q:
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.
Q:
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
Q:
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)
Q:
Q:
Assuming that t is an array and tPtr is a pointer to that array, what expression refers to the address of element 3?
(a) *(tPtr + 3)
(b) tPtr[3]
(c) &t[3]
(d) *(t + 3)
Q:
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.
Q:
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.
Q:
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
Q:
A pointer cannot 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
Q:
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
Q:
Which of the following can have a pointer as an operand?
(a) ++
(b) *=
(c) %
(d) /
Q:
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
Q:
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.
Q:
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)
Q:
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
Q:
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.
Q:
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
Q:
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
Q:
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.
Q:
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.
Q:
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.
Q:
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.
Q:
. 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.
Q:
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.
Q:
A function that prints a string should have a parameter that's a
(a) nonconstant pointer to nonconstant data.
(b) nonconstant pointer to constant data.
(c) constant pointer to nonconstant data.
(d) constant pointer to constant data.
Q:
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
Q:
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 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.
Q:
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
Q:
If array name arrayName is passed to a function, C automatically passes __________.
a) &arrayName[0]
b) arrayName[1]
c) arrayName[0]
d) *arrayName
Q:
When calling a function with arguments that should be modified, the __________ of those arguments are passed.
a) memory
b) addresses
c) values
d) complements
Q:
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 the calling function.
c) Call-by-value is always more efficient than call-by-reference.
d) In C, programmers use pointers and the indirection operator to simulate call-by-reference.
Q:
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
Q:
The unary * and __________ are complements of one another.
a) /
b) ^
c) &
d) |
Q:
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.