CS 150 Chapter 9 BS – Flashcards

Unlock all answers in this set

Unlock answers
question
Data in a struct variable must be read one member at a time.
answer
True
question
A struct variable can be passed as a parameter ____.
answer
either by value or by reference
question
In structs, you access a component by using the struct name together with the relative position of the component.
answer
False
question
You can declare struct variables when you define a struct.
answer
True
question
You can assign the value of one struct variable to another struct variable of ____ type.
answer
the same
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++?
answer
person2 = person1;
question
A function can return a value of the type array.
answer
False
question
You can use an assignment statement to copy the contents of one struct into another struct of the same type.
answer
True
question
A struct is typically a ____ data structure.
answer
heterogeneous
question
Typically, in a program, a struct is defined ____ in the program.
answer
before the definitions of all the functions
question
To compare struct variables, you compare them ____.
answer
member-wise
question
Which of the following struct definitions is correct in C++?
answer
struct studentType { int ID; };
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?
answer
bigRect.length = 10;
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?
answer
It is an array of structs.
question
An array name and index are separated using ____.
answer
square brackets
question
A function can return a value of the type struct.
answer
True
question
In C++, the ____ symbol is an operator, called the member access operator.
answer
.(dot)
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++?
answer
cout<<bigRect.length;
question
Consider the following function prototype: int seqSearch(const listType& list, int searchItem); The actual parameter cannot be modified by ____.
answer
list
question
A list has two items associated with it: ____.
answer
the values and the length
question
To access a structure member (component), you use the struct variable name together with the member name; these names are separated by a dot (period).
answer
True
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?
answer
for (int j = 0; j < 25; j++) applianceList.cost[j] = 0;
question
Consider the following statements. struct circleData { double radius; double area; double circumference; }; circleData circle; Which of the following statements is valid in C++?
answer
cin>>circle.radius;
question
Consider the following struct definition: struct rectangleData { double length; double width; double area; double perimeter; }; Which of the following variable declarations is correct?
answer
rectangleData myRectangle;
question
Which of the following aggregate operations can be executed on array variables?
answer
Parameter passing by reference
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++?
answer
student1.ID = student3.ID;
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?
answer
supplierType
question
Which of the following is an allowable aggregate operation on a struct?
answer
Assignment
question
Relational operations can be used on struct variables.
answer
False
question
The syntax for accessing a struct member is structVariableName____.
answer
.memberName
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New