Deck 9: Records (structs)

Full screen (f)
exit full mode
Question
The contents of a struct variable must be written one member at a time.
Use Space or
up arrow
down arrow
to flip the card.
Question
An array name and index are separated using ____.

A) curly brackets
B) square brackets
C) a dot
D) a comma
Question
Consider the following struct definition: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
Which of the following variable declarations is correct?

A) rectangle rectangleData;
B) struct rectangleData();
C) rectangleData myRectangle;
D) rectangleData rectangle = new rectangleData();
Question
The components of a struct are called the ____ of the struct.

A) variables
B) identifiers
C) elements
D) members
Question
Relational operations can be used on struct variables.
Question
In structs,you access a component by using the struct name together with the relative position of the component.
Question
A struct is typically a ____ data structure.

A) simple
B) dynamic
C) heterogeneous
D) linked
Question
You can declare struct variables when you define a struct.
Question
Which of the following struct definitions is correct in C++?

A) struct studentType
{
Int ID;
};
B) struct studentType
{
String name;
Int ID;
Double gpa;
}
C) int struct studentType
{
ID;
}
D) struct studentType
{
Int ID = 1;
};
Question
You can use an assignment statement to copy the contents of one struct into another struct of the same type.
Question
Typically,in a program,a struct is defined ____ in the program.

A) in the main function
B) before the definitions of all the functions
C) after the definitions of all the functions
D) in any function
Question
Aggregate input/output operations are allowed on a struct variable.
Question
A function can return a value of the type struct.
Question
The syntax for accessing a struct member is structVariableName____.

A) .memberName
B) *memberName
C) [memberName]
D) $memberName
Question
In C++,the ____ symbol is an operator,called the member access operator.

A) :(colon)
B) .(dot)
C) ,(comma)
D) $ (dollar sign)
Question
Consider the following statements: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
RectangleData bigRect;
Which of the following statements correctly initializes the component length of bigRect?

A) bigRect = {10};
B) bigRect.length = 10;
C) length[0]= 10;
D) bigRect[0]= 10
Question
A function can return a value of the type array.
Question
Data in a struct variable must be read one member at a time.
Question
You can use the assignment statement on structs.
Question
Consider the following statements: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
RectangleData bigRect;
Which of the following statements is valid in C++?

A) cin >> bigRect;
B) cin >> bigRect.length;
C) perimeter = 2 * (length + width);
D) area = length * width;
Question
Consider the following statements: struct personalInfo
{
String name;
Int age;
Double height;
Double weight;
};
Struct commonInfo
{
String name;
Int age;
};
PersonalInfo person1,person2;
CommonInfo person3,person4;
Which of the following statements is valid in C++?

A) person1 = person3;
B) person2 = person1;
C) person2 = person3;
D) person2 = person4;
Question
Both arrays and structs are examples of ____________________ data types.
Question
Consider the following function prototype: int seqSearch(const listType& list,int searchItem);
The actual parameter cannot be modified by ____.

A) seqSearch
B) listType
C) list
D) searchItem
Question
Consider the following statements: struct supplierType
{
String name;
Int supplierID;
};
Struct applianceType
{
SupplierType supplier;
String modelNo;
Double cost;
};
ApplianceType applianceList[25];
Which of the following best describes applianceList?

A) It is a multidimensional array.
B) It is a struct.
C) It is an array of structs.
D) It is a struct of arrays.
Question
A(n)____________________ is a collection of a fixed number of components in which the components are accessed by name.
Question
You can assign the value of one struct variable to another struct variable of ____ type.

A) a simple data
B) the same
C) an array
D) any
Question
Which of the following aggregate operations can be executed on array variables?

A) Arithmetic
B) Assignment
C) Function returning a value
D) Parameter passing by reference
Question
A struct is a(n)____________________,not a declaration.
Question
A list has two items associated with it: ____.

A) the length and the references
B) the values and the references
C) the indexes and the length
D) the values and the length
Question
Consider the following statements: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
RectangleData bigRect;
RectangleData smallRect;
Which of the following statements is legal in C++?

A) if (bigRect == smallRect)
B) if (bigRect != smallRect)
C) if (bigRect.length == width)
D) if (bigRect.length == smallRect.width)
Question
Consider the following statements: struct supplierType
{
String name;
Int supplierID;
};
Struct applianceType
{
SupplierType supplier;
String modelNo;
Double cost;
};
ApplianceType applianceList[25];
Which of the following statements correctly initializes the cost of each appliance to 0?

A) applianceList.cost = 0;
B) applianceList.cost[25] = 0;
C) for (int j = 1; j < 25; j++)
ApplianceList.cost[j] = 0;
D) for (int j = 0; j < 25; j++)
ApplianceList.cost[j] = 0;
Question
To compare struct variables,you compare them ____.

A) by reference
B) by value
C) index-wise
D) member-wise
Question
The following statement defines a struct houseType with a total of ____________________ member(s).
struct houseType
{
string style;
int numOfBedrooms;
int numOfBathrooms;
int numOfCarsGarage;
int yearBuilt;
};
Question
Consider the following statements: struct studentType1
{
String name;
Int ID;
Double gpa;
};
StudentType1 student1,student2;
Struct studentType2
{
String name;
Int ID;
Double gpa;
};
StudentType2 student3,student4;
Which of the following statements is valid in C++?

A) student2 = student3;
B) student1 = student4;
C) student2.ID = ID;
D) student1.ID = student3.ID;
Question
Memory is allocated for struct variables only when you ____________________ them.
Question
Which of the following is an allowable aggregate operation on a struct?

A) Arithmetic
B) Assignment
C) Input/output
D) Comparison
Question
Consider the following statements: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
RectangleData bigRect;
Which of the following statements is valid in C++?

A) cin >> bigRect.length >> width;
B) cout << bigRect.length;
C) cout << bigRect;
D) cout << length;
Question
Consider the following statements: struct supplierType
{
String name;
Int supplierID;
};
Struct paintType
{
SupplierType supplier;
String color;
String paintID;
};
PaintType paint;
What is the data type of paint.supplier?

A) string
B) paintType
C) supplierType
D) struct
Question
Consider the following statements. struct circleData
{
Double radius;
Double area;
Double circumference;
};
CircleData circle;
Which of the following statements is valid in C++?

A) cin >> circle.radius;
Circle.area = 3.14 * radius * radius;
B) cin >> circle.radius;
Circle.area = 3.14 * circle.radius * radius;
C) cin >> circle;
D) cin >> circle.radius;
Question
A struct variable can be passed as a parameter ____.

A) only by const
B) only by reference
C) only by value
D) either by value or by reference
Question
A(n)____________________ is a set of elements of the same type.
Question
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition in Figure 1.The statement ____________________ defines alumnus to be a struct variable of type newStudent.
Question
If a variable is passed by ____________________,then when the formal parameter changes,the actual parameter also changes.
Question
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition.The statement that assigns the average of testScore and programmingScore to score is ____________________.
Question
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition in Figure 1.The statement that initializes the member testScore to 95 is ____________________.
Question
Arrays are passed by ____________________ only.
Question
In C++,struct is a(n)____________________ word.
Question
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition in Figure 1.The statement that initializes the member firstName to Melissa is ____________________.
Question
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition in Figure 1.The statement cout ____________________ outputs the variables firstName and lastName separated by one space.
Question
Consider the following struct definition:
const int ARRAY_SIZE = 1000;
struct listType
{
int listElem[ARRAY_SIZE];
int listLength;
};
The statement that declares intList to be a struct variable of type listType is ____________________.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 9: Records (structs)
1
The contents of a struct variable must be written one member at a time.
True
2
An array name and index are separated using ____.

A) curly brackets
B) square brackets
C) a dot
D) a comma
B
3
Consider the following struct definition: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
Which of the following variable declarations is correct?

A) rectangle rectangleData;
B) struct rectangleData();
C) rectangleData myRectangle;
D) rectangleData rectangle = new rectangleData();
C
4
The components of a struct are called the ____ of the struct.

A) variables
B) identifiers
C) elements
D) members
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
Relational operations can be used on struct variables.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
In structs,you access a component by using the struct name together with the relative position of the component.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
A struct is typically a ____ data structure.

A) simple
B) dynamic
C) heterogeneous
D) linked
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
You can declare struct variables when you define a struct.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following struct definitions is correct in C++?

A) struct studentType
{
Int ID;
};
B) struct studentType
{
String name;
Int ID;
Double gpa;
}
C) int struct studentType
{
ID;
}
D) struct studentType
{
Int ID = 1;
};
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
You can use an assignment statement to copy the contents of one struct into another struct of the same type.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
Typically,in a program,a struct is defined ____ in the program.

A) in the main function
B) before the definitions of all the functions
C) after the definitions of all the functions
D) in any function
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
Aggregate input/output operations are allowed on a struct variable.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
A function can return a value of the type struct.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
The syntax for accessing a struct member is structVariableName____.

A) .memberName
B) *memberName
C) [memberName]
D) $memberName
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
In C++,the ____ symbol is an operator,called the member access operator.

A) :(colon)
B) .(dot)
C) ,(comma)
D) $ (dollar sign)
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
Consider the following statements: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
RectangleData bigRect;
Which of the following statements correctly initializes the component length of bigRect?

A) bigRect = {10};
B) bigRect.length = 10;
C) length[0]= 10;
D) bigRect[0]= 10
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
A function can return a value of the type array.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
Data in a struct variable must be read one member at a time.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
You can use the assignment statement on structs.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
Consider the following statements: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
RectangleData bigRect;
Which of the following statements is valid in C++?

A) cin >> bigRect;
B) cin >> bigRect.length;
C) perimeter = 2 * (length + width);
D) area = length * width;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
Consider the following statements: struct personalInfo
{
String name;
Int age;
Double height;
Double weight;
};
Struct commonInfo
{
String name;
Int age;
};
PersonalInfo person1,person2;
CommonInfo person3,person4;
Which of the following statements is valid in C++?

A) person1 = person3;
B) person2 = person1;
C) person2 = person3;
D) person2 = person4;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
Both arrays and structs are examples of ____________________ data types.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
Consider the following function prototype: int seqSearch(const listType& list,int searchItem);
The actual parameter cannot be modified by ____.

A) seqSearch
B) listType
C) list
D) searchItem
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
Consider the following statements: struct supplierType
{
String name;
Int supplierID;
};
Struct applianceType
{
SupplierType supplier;
String modelNo;
Double cost;
};
ApplianceType applianceList[25];
Which of the following best describes applianceList?

A) It is a multidimensional array.
B) It is a struct.
C) It is an array of structs.
D) It is a struct of arrays.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
A(n)____________________ is a collection of a fixed number of components in which the components are accessed by name.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
You can assign the value of one struct variable to another struct variable of ____ type.

A) a simple data
B) the same
C) an array
D) any
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following aggregate operations can be executed on array variables?

A) Arithmetic
B) Assignment
C) Function returning a value
D) Parameter passing by reference
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
A struct is a(n)____________________,not a declaration.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
A list has two items associated with it: ____.

A) the length and the references
B) the values and the references
C) the indexes and the length
D) the values and the length
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
Consider the following statements: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
RectangleData bigRect;
RectangleData smallRect;
Which of the following statements is legal in C++?

A) if (bigRect == smallRect)
B) if (bigRect != smallRect)
C) if (bigRect.length == width)
D) if (bigRect.length == smallRect.width)
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
Consider the following statements: struct supplierType
{
String name;
Int supplierID;
};
Struct applianceType
{
SupplierType supplier;
String modelNo;
Double cost;
};
ApplianceType applianceList[25];
Which of the following statements correctly initializes the cost of each appliance to 0?

A) applianceList.cost = 0;
B) applianceList.cost[25] = 0;
C) for (int j = 1; j < 25; j++)
ApplianceList.cost[j] = 0;
D) for (int j = 0; j < 25; j++)
ApplianceList.cost[j] = 0;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
To compare struct variables,you compare them ____.

A) by reference
B) by value
C) index-wise
D) member-wise
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
The following statement defines a struct houseType with a total of ____________________ member(s).
struct houseType
{
string style;
int numOfBedrooms;
int numOfBathrooms;
int numOfCarsGarage;
int yearBuilt;
};
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
Consider the following statements: struct studentType1
{
String name;
Int ID;
Double gpa;
};
StudentType1 student1,student2;
Struct studentType2
{
String name;
Int ID;
Double gpa;
};
StudentType2 student3,student4;
Which of the following statements is valid in C++?

A) student2 = student3;
B) student1 = student4;
C) student2.ID = ID;
D) student1.ID = student3.ID;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
Memory is allocated for struct variables only when you ____________________ them.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following is an allowable aggregate operation on a struct?

A) Arithmetic
B) Assignment
C) Input/output
D) Comparison
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
Consider the following statements: struct rectangleData
{
Double length;
Double width;
Double area;
Double perimeter;
};
RectangleData bigRect;
Which of the following statements is valid in C++?

A) cin >> bigRect.length >> width;
B) cout << bigRect.length;
C) cout << bigRect;
D) cout << length;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
Consider the following statements: struct supplierType
{
String name;
Int supplierID;
};
Struct paintType
{
SupplierType supplier;
String color;
String paintID;
};
PaintType paint;
What is the data type of paint.supplier?

A) string
B) paintType
C) supplierType
D) struct
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
Consider the following statements. struct circleData
{
Double radius;
Double area;
Double circumference;
};
CircleData circle;
Which of the following statements is valid in C++?

A) cin >> circle.radius;
Circle.area = 3.14 * radius * radius;
B) cin >> circle.radius;
Circle.area = 3.14 * circle.radius * radius;
C) cin >> circle;
D) cin >> circle.radius;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
A struct variable can be passed as a parameter ____.

A) only by const
B) only by reference
C) only by value
D) either by value or by reference
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
A(n)____________________ is a set of elements of the same type.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition in Figure 1.The statement ____________________ defines alumnus to be a struct variable of type newStudent.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
If a variable is passed by ____________________,then when the formal parameter changes,the actual parameter also changes.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition.The statement that assigns the average of testScore and programmingScore to score is ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition in Figure 1.The statement that initializes the member testScore to 95 is ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
Arrays are passed by ____________________ only.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
In C++,struct is a(n)____________________ word.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition in Figure 1.The statement that initializes the member firstName to Melissa is ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
Figure 1:
struct newStudent
{
string firstName;
string lastName;
string courseGrade;
int testScore;
int programmingScore;
};
int score;
Consider the accompanying struct definition in Figure 1.The statement cout ____________________ outputs the variables firstName and lastName separated by one space.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
Consider the following struct definition:
const int ARRAY_SIZE = 1000;
struct listType
{
int listElem[ARRAY_SIZE];
int listLength;
};
The statement that declares intList to be a struct variable of type listType is ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.