Deck 12: Structures
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
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/48
Play
Full screen (f)
Deck 12: Structures
1
In the broadest sense, the term "structure" refers to how individual elements of a group are arranged or organized.
True
2
In dealing with structures, it is important to distinguish between a structure's form and its contents.
True
3
A structure's contents consist of the symbolic names, data types, and arrangement of individual data fields in the record.
False
4
The structure's form consists of the actual data stored in the symbolic names.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
5
Populating a structure is a complex task in C.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
6
birth.month refers to the birth member of the month structure.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
7
As in most C statements, the spacing of a structure definition is not rigid.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
8
A structure definition statement is identical to the form used in defining any program variable: the data type is followed by a list of variable names.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
9
When defining structures, if the form of the structure is not followed by any variable names, the list of structure members must be preceded by a user-selected structure type name.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
10
A structure may be declared globally or locally.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
11
A record is a homogeneous data structure.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
12
An array is a heterogeneous data structure.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
13
The real power of structures is realized when they are used in an array.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
14
By convention all typedef names are written in lowercase.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
15
Within a set of parallel arrays, all of the elements with the same subscript value would refer to information corresponding to the same individual.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
16
The problem with arrays of structures is that the correspondence between data items is easily lost if only one of the arrays is reordered.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
17
Parallel arrays are rarely used anymore because almost all programming languages currently provide structures.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
18
On all compilers, complete copies of all members of a structure can be passed to a function by including the name of the structure as an argument to the called function.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
19
A globally-defined structure type centralizes the declaration of the structure's organization.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
20
When passing a structure to a function, the calling function and the called function must both refer to the same globally defined structure type.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
21
*(pt.hours) refers to the variable whose address is in the pt.hours variable.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
22
The -> operator has a lower priority than the increment operator.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
23
The declaration for a union is identical in form to a structure declaration, with the reserved word union used in place of the reserved word struct.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
24
When working with unions, typically a second variable keeps track of the current data type stored in the union.
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
25
Each of the individual data items in a "structure" or single unit is an entity by itself that is referred to as a ____.
A)record
B)union
C)data structure
D)data field
A)record
B)union
C)data structure
D)data field
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
26
Taken together, all the data fields form a single unit that is referred to as a(n) ____.
A)record
B)union
C)tuple
D)array
A)record
B)union
C)tuple
D)array
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
27
In C, a record is referred to as a(n) ____.
A)data field
B)union
C)structure
D)tuple
A)data field
B)union
C)structure
D)tuple
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
28
Assigning actual data values to the data items of a structure is called ____ the structure.
A)populating
B)filling
C)fattening
D)completing
A)populating
B)filling
C)fattening
D)completing
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
29
Each member of a structure is accessed by giving both the structure name and individual data item name, separated by a ____.
A)@
B)->
C):
D))
A)@
B)->
C):
D))
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
30
____ is not a valid C statement.
A)struct {int month; int day; int year;} birth;
B)struct {int month; int day; int year;} birth, current;
C)struct Date {int month; int day; int year;};
D)struct {int month, int day, int year} birth;
A)struct {int month; int day; int year;} birth;
B)struct {int month; int day; int year;} birth, current;
C)struct Date {int month; int day; int year;};
D)struct {int month, int day, int year} birth;
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
31
In the following definition, ____ is the structure type name.
Struct Date
{
Int month;
Int day;
Int year;
} birth, current;
A)Date
B)month
C)birth
D)current
Struct Date
{
Int month;
Int day;
Int year;
} birth, current;
A)Date
B)month
C)birth
D)current
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
32
____ creates a new data type without actually reserving any storage locations.
A)struct {int month; int day; int year;} birth;
B)struct {int month; int day; int year;} birth, current;
C)struct Date {int month; int day; int year;};
D)struct Date {int month; int day; int year;} birth;
A)struct {int month; int day; int year;} birth;
B)struct {int month; int day; int year;} birth, current;
C)struct Date {int month; int day; int year;};
D)struct Date {int month; int day; int year;} birth;
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
33
____ is not a definition statement.
A)struct {int month; int day; int year;} birth;
B)struct {int month; int day; int year;} birth, current;
C)struct Date {int month; int day; int year;};
D)struct Date {int month; int day; int year;} birth;
A)struct {int month; int day; int year;} birth;
B)struct {int month; int day; int year;} birth, current;
C)struct Date {int month; int day; int year;};
D)struct Date {int month; int day; int year;} birth;
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
34
After the following declaration, you can define and initialize a variable birth of this structure type as follows ____.
Struct Date
{
Int month;
Int day;
Int year;
};
A)Date birth = {12, 28, 1987};
B)struct Date birth = {12, 28, 1987};
C)Date birth = {12; 28; 1987};
D)struct Date birth = {12; 28; 1987};
Struct Date
{
Int month;
Int day;
Int year;
};
A)Date birth = {12, 28, 1987};
B)struct Date birth = {12, 28, 1987};
C)Date birth = {12; 28; 1987};
D)struct Date birth = {12; 28; 1987};
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
35
For non-ANSI C compilers, the keyword ____ must be placed before the keyword struct for initialization within a local declaration statement.
A)unsigned
B)const
C)init
D)static
A)unsigned
B)const
C)init
D)static
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
36
Arrays of structures are very useful to replace ____ arrays.
A)parallel
B)two-dimensional
C)multi-dimensional
D)static
A)parallel
B)two-dimensional
C)multi-dimensional
D)static
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
37
A ____ statement provides a simple method for creating a new and typically shorter name for an existing structure type.
A)#define
B)typedef
C)set
D)union
A)#define
B)typedef
C)set
D)union
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
38
If you have declared a structure named Date, you can then make the name DATE a synonym for the terms struct Date, by using the statement ____.
A)typedef struct Date DATE;
B)typedef DATE struct Date;
C)#define struct Date DATE
D)#define DATE struct Date
A)typedef struct Date DATE;
B)typedef DATE struct Date;
C)#define struct Date DATE
D)#define DATE struct Date
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
39
____ creates an array of 10 PayRecord structures.
A)struct (PayRecord employee)[10];
B)struct[10] PayRecord employee;
C)struct PayRecord[10] employee;
D)struct PayRecord employee[10];
A)struct (PayRecord employee)[10];
B)struct[10] PayRecord employee;
C)struct PayRecord[10] employee;
D)struct PayRecord employee[10];
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
40
Suppose employee is an array of 10 PayRecord structures. ____ accesses the rate member of the first structure in the employee array.
A)employee.[0]rate
B)employee.rate[0]
C)employee[0].rate
D)(employee.rate)[0]
A)employee.[0]rate
B)employee.rate[0]
C)employee[0].rate
D)(employee.rate)[0]
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
41
____ arrays are two or more arrays, where each array has the same number of elements and the elements in each array are directly related by their position in the arrays.
A)Two-dimensional
B)Multi-dimensional
C)Parallel
D)Complex
A)Two-dimensional
B)Multi-dimensional
C)Parallel
D)Complex
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
42
The statement ____ passes a copy of the structure member emp.idNum to a function named display().
A)display(*emp.idNum);
B)display(emp.idNum);
C)display(&emp.idNum);
D)display(emp->idNum);
A)display(*emp.idNum);
B)display(emp.idNum);
C)display(&emp.idNum);
D)display(emp->idNum);
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
43
The function call ____ passes a copy of the complete emp structure to calcNet().
A)calcNet(struct emp);
B)calcNet(*emp);
C)calcNet(&emp);
D)calcNet(emp);
A)calcNet(struct emp);
B)calcNet(*emp);
C)calcNet(&emp);
D)calcNet(emp);
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
44
If pt is declared as a pointer to a structure of type Employee, ____ refers to the idNum member of the structure.
A)(*pt).idNum
B)*pt.idNum
C)*(pt.idNum)
D)(*pt.)idNum
A)(*pt).idNum
B)*pt.idNum
C)*(pt.idNum)
D)(*pt.)idNum
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
45
If pt is declared as a pointer to a structure of type Employee, ____ refers to the variable whose address is in the pt.idNum variable.
A)(*pt).idNum
B)*pt.idNum
C)pt->idNum
D)(*pt.)idNum
A)(*pt).idNum
B)*pt.idNum
C)pt->idNum
D)(*pt.)idNum
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
46
____ is equivalent to (*pointer).member.
A)pointer.member
B)pointer>member
C)pointer->member
D)pointer@member
A)pointer.member
B)pointer>member
C)pointer->member
D)pointer@member
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
47
A(n) ____ is a data type that reserves the same area in memory for two or more variables, each of which can be a different data type.
A) array
C) structure
B) register
D) union
A) array
C) structure
B) register
D) union
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck
48
A union reserves sufficient memory locations to accommodate ____.
A) its smallest member's data type
C) all of its members' data types
B) its largest member's data type
D) none of its members' data types
A) its smallest member's data type
C) all of its members' data types
B) its largest member's data type
D) none of its members' data types
Unlock Deck
Unlock for access to all 48 flashcards in this deck.
Unlock Deck
k this deck