Deck 22: Bits, Characters, C Strings and Structs
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/26
Play
Full screen (f)
Deck 22: Bits, Characters, C Strings and Structs
1
Evaluate 00001000 & 11000101 ) ^ 11110000 ).
A) 00001101
B) 11000000
C) 00111101
D) 11110000
A) 00001101
B) 11000000
C) 00111101
D) 11110000
D
2
Arrays are:
A) Always passed by reference.
B) Passed by reference unless inside a structure.
C) Passed by reference unless their elements are structures.
D) Always passed by value.
A) Always passed by reference.
B) Passed by reference unless inside a structure.
C) Passed by reference unless their elements are structures.
D) Always passed by value.
B
3
The strtol and stroul functions do not:
A) Need a header file to be used.
B) Take three arguments.
C) Have the same return types.
D) Have the ability to return data in base 8.
A) Need a header file to be used.
B) Take three arguments.
C) Have the same return types.
D) Have the ability to return data in base 8.
C
4
A bit field must be declared as a:
A) int or unsigned.
B) char.
C) float.
D) long.
A) int or unsigned.
B) char.
C) float.
D) long.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
5
Two structure variables of the same type with the same member values, when compared will:
A) Always compare equally.
B) Never compare equally.
C) Sometimes compare equally.
D) Result in a compile error.
A) Always compare equally.
B) Never compare equally.
C) Sometimes compare equally.
D) Result in a compile error.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
6
Which is the proper way to create an array of structure variables of type Data?
A) MyArray Data[ 10 ]
B) Data MyArray[ 10 ];
C) Data struct myArray[ 10 ];
D) struct MyArray[ Data ];
A) MyArray Data[ 10 ]
B) Data MyArray[ 10 ];
C) Data struct myArray[ 10 ];
D) struct MyArray[ Data ];
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
7
The most basic unit of data on a computer is the:
A) Bit.
B) Byte.
C) File.
D) int.
A) Bit.
B) Byte.
C) File.
D) int.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
8
The isxdigit function would return false on:
A) a
B) A
C) 2
D) g
A) a
B) A
C) 2
D) g
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
9
__________ is not allowed.
A) Accessing individual bits in a multi-bit bit field.
B) Padding a bit field with bits that cannot be accessed.
C) Having an unnamed bit field.
D) Having a bit field with a zero width.
A) Accessing individual bits in a multi-bit bit field.
B) Padding a bit field with bits that cannot be accessed.
C) Having an unnamed bit field.
D) Having a bit field with a zero width.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
10
For any nonzero 8-bit x, which of the following does not result in zero?
A) x &= ~x )
B) x ^= x
C) x <<= 8
D) x |= x
A) x &= ~x )
B) x ^= x
C) x <<= 8
D) x |= x
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
11
The advantages of using 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.
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.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
12
Structure variables may not be initialized by:
A) Assigning user-defined values in the struct definition.
B) Assigning values to individual data members.
C) Array-like member initializer lists.
D) Assigning the value of another structure variable of the same type.
A) Assigning user-defined values in the struct definition.
B) Assigning values to individual data members.
C) Array-like member initializer lists.
D) Assigning the value of another structure variable of the same type.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
13
Typedef is used to:
A) Create a type name that is an alias for another type name.
B) Make a struct private.
C) Cast one struct to another type.
D) Initialize struct members.
A) Create a type name that is an alias for another type name.
B) Make a struct private.
C) Cast one struct to another type.
D) Initialize struct members.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
14
Let x be an unsigned int on a machine with 4-byte unsigned ints. What effect does
X>>=1;
X<<=1;
Have?
A) There is no effect.
B) The leftmost bit of x is set to 0.
C) The rightmost bit of x is set to 0.
D) Both b) and c).
X>>=1;
X<<=1;
Have?
A) There is no effect.
B) The leftmost bit of x is set to 0.
C) The rightmost bit of x is set to 0.
D) Both b) and c).
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
15
Let Bit1 = Bit2 = 1. Which of the following does not have the same result as the others?
A) Bit1 & Bit2
B) Bit1 | Bit2
C) Bit1 ^ Bit2
D) ~ ~Bit2 )
A) Bit1 & Bit2
B) Bit1 | Bit2
C) Bit1 ^ Bit2
D) ~ ~Bit2 )
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
16
The main difference between structures and classes is:
A) Whether they default to public or private access.
B) How they access member variables.
C) That classes always require new be used with them while structures do not.
D) There is no difference between structures and classes.
A) Whether they default to public or private access.
B) How they access member variables.
C) That classes always require new be used with them while structures do not.
D) There is no difference between structures and classes.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
17
The number of bits in a bit field is specified with:
A) Parentheses as in bitfield 4 )
B) A colon as in bitfield : 4
C) Brackets as in bitfield[ 4 ]
D) A dot as in bitfield.4
A) Parentheses as in bitfield 4 )
B) A colon as in bitfield : 4
C) Brackets as in bitfield[ 4 ]
D) A dot as in bitfield.4
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
18
The functions of the character-handling library typically manipulate characters as:
A) ints
B) floats
C) longs
D) chars
A) ints
B) floats
C) longs
D) chars
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is not a bitwise operator?
A) ^
B) >>
C) ~
D) *
A) ^
B) >>
C) ~
D) *
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
20
Structure variable declarations can be incorporated into a structure definition by placing a comma-separated list of variable names:
A) After struct StructureName and before the left brace.
B) After the left brace and before the member declarations.
C) After the member declarations and before the right brace.
D) After the right brace and before the semicolon.
A) After struct StructureName and before the left brace.
B) After the left brace and before the member declarations.
C) After the member declarations and before the right brace.
D) After the right brace and before the semicolon.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
21
What is the output of the following statement?
Cout << strspn"Cows like to moo.", "Ceik losw");
A) Nothing.
B) 10.
C) 8.
D)
E)
Cout << strspn"Cows like to moo.", "Ceik losw");
A) Nothing.
B) 10.
C) 8.
D)
E)
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
22
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.
A) strcspn.
B) strchr.
C) strstr.
D) strrchr.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
23
To change the string "ABCDEFGHI" to "aaaaaFGHI" you would use the _________ function.
A) memset
B) memcmp
C) memchr
D) memcopy
A) memset
B) memcmp
C) memchr
D) memcopy
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
24
The ___________ function allows characters of one part of a string to be copied into another, overlapping part of the same string.
A) memchr
B) memcmp
C) memcpy
D) memmove
A) memchr
B) memcmp
C) memcpy
D) memmove
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
25
Memcmp would return ___________ for the call memcmp"Hi, how are you?", "Hi, how are things?", 6).
A) 1
B) A positive number.
C) 0
D) A negative number.
A) 1
B) A positive number.
C) 0
D) A negative number.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
26
The main difference between the functions atof, atoi and atol is:
A) Their return types.
B) Their arguments.
C) Their header files.
D) Their efficiency.
A) Their return types.
B) Their arguments.
C) Their header files.
D) Their efficiency.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck