Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Programming Language
Q:
Which statement is true?
a) The members of a union can be of any type.
b) The members of a union must all be of the same type.
c) A union may not be assigned to another union of the same type.
d) Unions may be compared to other unions of the same type.
Q:
Which of the following is true?
a) A union typically makes less efficient use of memory than a struct.
b) A union is another name for a struct.
c) A union is a derived data type whose members share the same storage space.
d) Unions are always portable between different computers with different compilers.
Q:
Which of the following is not an operation that can be performed on a union?
(a) comparing using the != operator
(b) taking the address (&) of a union
(c) accessing union members using the structure member operator
(d) assigning a union to another union of the same type
Q:
Which of the following is true?
(a) Unions may be compared using the == operator.
(b) The address operator (&) cannot be used to take the address of a union.
(c) Unions may only contain two data types.
(d) Only one union member, and thus one data type, can be referenced at a time
Q:
Which of the following is always a syntax error?
a) Not using srand in every program that uses rand.
b) Not using rand in every program that uses srand.
c) Not using const when passing an array.
d) Forgetting to include the array subscript when referring to individual structures in an array of structures.
Q:
What does the statement typedef struct card Card; do?
a) Defines card as a synonym for Card.
b) Defines Card as a synonym for card.
c) Defines Card as a synonym for struct card.
d) Defines Card as a synonym for typedef struct card.
Q:
Which statement is true?
a) Often, typedef is used to create synonyms for the basic data types.
b) Keyword typedef is used to create antonyms (or opposites) for the basic data types.
c) Names for structure types are typically defined with typedef to create longer type names.
d) The first letter of each typedef name must be capitalized.
Q:
Creating a new name with typedef __________.
a) creates a new type
b) creates a new type name
c) creates a new variable name
d) creates a new variable
Q:
Advantages of typedef do not include
(a) making programs more portable by allowing data types to be easily changed to meet system specifications.
(b) making type names shorter.
(c) making programs more readable.
(d) increasing the efficiency of accessing struct member variables.
Q:
typedef is used to
(a) create a name that is an alias for a previously defined data type.
(b) create new data types.
(c) cast one struct to another type.
(d) initialize struct members.
Q:
. Which of the following is false?
a) To pass a structure by reference, pass the address of the structure variable.
b) A way to pass an array by value, is to create a structure with the array as a member then pass the name of the structure.
c) To pass a structure by reference, pass the name of the structure variable.
d) Passing large structures by reference is more efficient than passing large structures by value.
Q:
. An array of structures is automatically passed __________.
a) by value
b) by reference
c) by aggregate
d) by enumeration
Q:
. A structure of arrays is automatically passed __________.
a) by value
b) by reference
c) by aggregate
d) by masking
Q:
Arrays of structures ________.
(a) are automatically passed by reference
(b) are automatically passed by value
(c) cannot be passed by reference
(d) None of the above.
Q:
Structures may be passed to functions by ________.
(a) passing individual structure members
(b) passing an entire structure
(c) passing a pointer to the structure
(d) all of these
Q:
. Which of the following is false?
a) Structure member names throughout a program must be unique.
b) Attempting to refer to a member of a structure by using only the member's name is an error.
c) Inserting a space between the - and > of operator -> is an error.
d) The dot operator (.) is the structure member operator.
Q:
. The expression aptr->suit is equivalent to __________.
a) aptr.suit
b) *aptr.suit
c) (*aptr).suit
d) *aptr.(suit)
Q:
The ________ accesses a structure member via the structure variable name.
(a) structure member operator
(b) structure pointer operator
(c) structure arrow operator
(d) none of these
Q:
Arrays are
(a) always passed call-by-reference.
(b) passed call-by-reference unless inside a structure.
(c) always passed call-by-value.
(d) passed call-by-value unless inside a structure.
Q:
. Structures can be initialized in __________ statements.
a) assignment
b) null
c) scope
d) empty
Q:
. If there are fewer __________ in the list than members in the structure, the remaining members are automatically initialized to 0 or NULL.
a) quantifiers
b) initializers
c) numerators
d) variables
Q:
What does the following statement do?
struct card a = {"Three", "Hearts"};
(a) It creates a variable card of type struct with two members specified in the list.
(b) It creates two variables named Three and Hearts of type struct card a.
(c) It creates a variable a to be of type struct card and initializes it to the values in the list.
(d) It creates two variables named Three and Hearts of type struct card.
Q:
Structure variables may not be initialized by
(a) setting user-defined default variable values in the struct definition.
(b) assigning values to individual data members.
(c) array-like member initializer lists.
(d) assignment statements.
Q:
. Which of the following is not a valid operation on a structure?
a) Assigning structure variables to structure variables of the same type.
b) Taking the address of a structure variable.
c) Using the sizeof operator to determine the size of a structure variable.
d) Comparing structures of the same type with relational operators.
Q:
. Which statement is false?
a) Structures are derived data types.
b) Each structure definition must end with a semicolon.
c) A structure can contain an instance of itself.
d) Structures may not be compared using operators == and !=.
Q:
. A structure containing a member that's a pointer to the same structure type is referred to as a __________ structure.
a) self-referential
b) self-describing
c) self-recursive
d) self- elemental
Q:
. Keyword __________ introduces the structure definition.
a) structure
b) str
c) strdef
d) struct
Q:
What does the deck[52] array contain in the following statement?
struct card a, deck[52], *cPtr;
(a) card structure elements
(b) a structure elements
(c) *cPtr elements
(d) none of these
Q:
Two structure variables with the same member values
(a) always compare equally.
(b) never compare equally.
(c) sometimes compare equally.
(d) only compare equally if both structure variables contain holes.
Q:
. Structures may contain variables of many different data typesin contrast to ___________ that contain only elements of the same data type.
a) files
b) arrays
c) constants
d) functions
Q:
. __________ are collections of related variablessometimes referred to as aggregatesunder one name.
a) Members
b) Enumerations
c) Structures
d) Files
Q:
________ may contain different data types.
(a) structures
(b) arrays
(c) both a and b
(d) none of these
Q:
Which of the following statements is true?
(a) Allowing multiple enumeration constants to have the same value can result in difficult-to-find logic errors.
(b) Performing bitwise operations on integer types smaller than int always yields correct results.
(c) Bitwise operations on signed and unsigned integer types are portable across platforms.
(d)None of the above.
Q:
Which of the following statements is true?
(a) The size of a struct variable is the sum of its members' sizes.
(b) struct variables can be compared for equality or inequality.
(c) In a struct variable, undefined extra bytes could contain secure dataleft over from prior use of those memory locationsthat should not be accessible.
(d)None of the above.
Q:
Which statement is true?
a) The identifiers in an enumeration must be unique.
b) The constant values assigned to members of an enumeration must be unique.
c) Enumeration constant names must consist of all uppercase letters.
d) Values in an enumeration start with 1 unless specified otherwise.
Q:
Which statement is false?
a) Assigning a value to an enumeration constant when creating an enumeration type causes a syntax error.
b) An enumeration is a set of integer constants represented by identifiers.
c) Enumeration constant values can be set automatically.
d) Assigning a value to an enumeration constant after it has been defined is a syntax error.
Q:
Enumeration constants within an enumeration
(a) must have unique integer values
(b) can be assigned other values once they have been defined
(c) must have unique identifiers
(d) are defined using the keyword const
Q:
Which statement is false?
a) Using bit fields can be an effective space saving technique.
b) Using bit fields always results in faster executing machine language.
c) The decision to use bit fields is one of many examples of the kinds of space-time tradeoffs that occur in computer science.
d) An unnamed bit field with a non-zero width is used as padding in a struct of bit fields.
Q:
An unnamed bit field with a zero width is used to __________.
a) purge a bit from a bit field
b) initialize a bit field to 0.
c) concatenate two bit fields.
d) align the next bit field on a new storage unit boundary.
Q:
Which statement is false?
a) Bit field manipulations are machine dependent.
b) Bit fields may never cross a word boundary.
c) Bit fields are not "arrays of bits."
d) It is not possible to take the address of a bit field.
Q:
__________ is not allowed.
(a) Accessing individual bits in a multi-bit bitfield.
(b) Padding a bitfield with bits that cannot be accessed
(c) Having an unnamed bitfield.
(d) Having a bitfield with a zero width.
Q:
The number of bits in a bitfield is specified with __________.
(a) parenthesis as in bitfield(4)
(b) a colon as in bitfield : 4
(c) brackets as in bitfield[4]
(d) a dot as in bitfield.4
Q:
A bitfield must be defined as a __________.
(a) int or unsigned
(b) char
(c) float
(d) long
Q:
Which statement is false?
a) The result of shifting a value is undefined if the right operand is negative.
b) The result of shifting a value is undefined if the right operand has more bits than the number of bits in which the left operand is stored.
c) Left shifting is machine dependent.
d) Right shifting is machine dependent.
Q:
Which statement is true?
a) || is the bitwise or operator,
b) | is the logical or operator
c) Operators || and | are interchangeable.
d) || and | are each binary operators.
Q:
Which of the following statements is false?
(a) In general, as you study any programming language, if the language specification says that doing something can lead to undefined behavior, avoid doing it to prevent security vulnerabilities.
(b) The C standard specifies the exact behavior for every case in which incorrect library-function arguments are passed to a library function.
(c) Undefined behaviors can occur when using printf with improperly formed conversion specifications.
(d)None of the above.
Q:
Which statement about scan sets is false?
a) A scan set is a set of characters enclosed in parentheses and preceded by a percent sign in the format control string.
b) A scan set scans the characters in the input stream looking only for those characters that match the characters contained in the scan set.
c) Each time a character in the input stream matches a character in the scan set, the input stream character is stored in the scan set's corresponding argumenta pointer to a character array.
d) The scan set stops inputting characters when a character that is not contained in the scan set is encountered.
Q:
The %i scanf conversion specifier is not capable of inputting which type of data?
a) hexadecimal
b) binary
c) decimal
d) octal
Q:
Which is not an input formatting capability of scanf?
a) inputting all types of data
b) inputting specific characters from an input stream
c) skipping specific characters in the input stream
d) replacing specific characters in the input stream
Q:
The ________ character reads data from the input stream and discards the data.
(a) %
(b) conversion specifier
(c) assignment suppression
(d) //
Q:
A field width ________ be included in the format control string of the scanf statement.
(a) can
(b) cannot
(c) must
(d) none of these
Q:
Q:
What does the \ do when used in a format control string?
(a) It outputs the backslash character
(b) It delimits comments
(c) both a and b
(d) none of these
Q:
Q:
Which statement is false with regard to format control string flags?
a) The plus sign is only displayed when the + flag is used.
b) The minus sign is always displayed (when the value being printed is negative).
c) To use a flag in a format control string, place the flag immediately to the left of the percent sign.
d) Use the 0 flag to pad a field with leading zeros.
Q:
Which is not a format control string flag?
a) "
b) space
c) newline
d) #
Q:
Which of the following is the correct way to output the value of 4 left justified?
(a) printf( "%i", 4 );
(b) printf( "%-i", 4 );
(c) printf( "4%i", 4 );
(d) printf( "4-%i", 4 );
Q:
Which of the following is not a flag that can be used in the printf format-control string?
(a) 0
(b) +
(c) /
(d) #
Q:
If the field width is larger than the data being printed, the data will normally be __________ within that field.
a) truncated
b) right justified
c) centered
d) left justified
Q:
The statement
printf( "%*.*f", 7, 2, 98.736 );
uses _______ for the precision, __________ for the field width and outputs the value 98.74 __________.
a) 7, 2, left justified
b) 2, 7, left justified
c) 2, 7, right justified
d) 7, 2, right justified
Q:
What would be the output of the following statement?
printf( "%4d", 123456 );
(a) 1234
(b) 2345
(c) 3456
(d) none of these
Q:
What does the 4 signify in the follwing statement?
printf( "%4i
", 123 );
(a) degree of exponentiation
(b) floating point precision
(c) a field width
(d) none of these
Q:
Conversion specifier p __________.
a) displays a pointer value with -> notation
b) displays a pointer value in hexadecimal notation
c) displays a pointer value in decimal notation
d) displays a pointer value in an implementation-defined manner.
Q:
Which of the following would output a "%" sign when used in the format control string of the printf statement?
(a) %/
(b) /%
(c) %%
(d) none of these
Q:
Which is not a common programming error with regard to the character and string conversion specifiers.
a) Using %c to print a string.
b) Using %s to print a char argument
c) Using double quotes around a character string
d) Using double quotes around a character constant
Q:
Conversion specifier s requires a(n) __________ argument.
a) pointer to char
b) char
c) integer
d) ASCII numeric
Q:
Conversion specifier c requires a(n) __________ argument.
a) pointer to char
b) char
c) integer
d) ASCII numeric
Q:
What would be the output of the following statement?
char* value = 'hello';
printf( '%s', value );
(a) h
(b) hello
(c) value
(d) none of these
Q:
What would be the output of the following statements?
char* value = "hello";
printf( "%c", value );
(a) h
(b) hello
(c) value
(d) none of these
Q:
With the %g conversion specifier, the value 0.0000875 prints as
a) 8.75e-05
b) 87.5e-06
c) 0.875e-04
d) 0 (because of truncation)
Q:
Conversion specifiers g or G always print __________.
a) no trailing zeros
b) one trailing zero
c) as many trailing zeros as are in the number itself
d) a default of six trailing zeros
Q:
Conversion specifiers e and E always print exactly __________ to the left of the decimal point.
a) zero digits
b) one digit
c) two digits
d) three digits
Q:
Values printed with the conversion specifiers e, E and f are output with __________ digits of precision to the right of the decimal point by default.
a) 0
b) 1
c) 5
d) 6
Q:
In 1.504582E+02, the E+02 indicates that __________.
a) 1.504582 is to be raised to the second power
b) 1.504582 is to be extended by two print positions
c) 1.504582 is to be multiplied by 100
d) 1.504582 is to be doubled
Q:
The floating-point conversion specifiers e and E display floating-point values in __________ notation.
a) elliptical
b) existential
c) exponential
d) exportable
Q:
A floating-point value always contains a __________.
a) decimal point
b) comma
c) plus sign
d) e or E
Q:
The %g conversion specifier indicates ________.
(a) color
(b) significant digits
(c) a global variable
(d) a hexadecimal integer
Q:
The %e conversion specifier displays ________ values.
(a) long
(b) character
(c) integer
(d) floating-point
Q:
Which statement about integer conversion specifiers is false?
a) It is an error to print a negative value with a conversion specifier that expects an unsigned value.
b) "455 when printed with %u prints 455.
c) When printing an integers with %d, the plus sign (on a positive integer) does not print.
d) Place an l ("el") before any integer conversion specifier to indicate that a long integer is displayed.
Q:
Place __________ before any integer conversion specifier to indicate that a short integer is to be displayed.
a) s
b) S
c) h
d) H