T/F?
A function can return a value of the type array.
question
True
answer
T/F?
A function can return a value of the type struct.
question
the values and the length
answer
A list has two items associated with it: ____.
question
definition
answer
A struct is a(n) ____________________, not a declaration.
question
heterogeneous
answer
A struct is typically a ____ data structure.
question
either by value or by reference
answer
A struct variable can be passed as a parameter ____.
question
False
answer
T/F?
Aggregate input/output operations are allowed on a struct variable.
question
square brackets
answer
An array name and index are separated using ____.
question
reference
answer
Arrays are passed by ____________________ only.
question
list
answer
Consider the following function prototype:
int seqSearch(const listType& list, int searchItem);
The actual parameter cannot be modified by ____.
a. list
b. seqSearch
c. searchItem
d. listType
question
cin >> circle.radius;
answer
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 * circle.radius *
radius;
b. cin >> circle.radius;
c. cin >> circle.radius;
circle.area = 3.14 * radius * radius;
d. cin >> circle;
question
person2 = person1;
answer
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 = person4;
c. person2 = person3;
d. person2 = person1;
question
bigRect.length = 10;
answer
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.length = 10;
b. bigRect[0]= 10
c. bigRect = {10};
d. length[0]= 10
question
cin >> bigRect.length;
answer
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
if (bigRect.length == smallRect.width)
answer
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 ==
smallRect.width)
d. if (bigRect.length == width)
question
cout << bigRect.length;
answer
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 << length;
c. cout << bigRect;
d. cout << bigRect.length;
question
student1.ID = student3.ID;
answer
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. student1.ID = student3.ID;
b. student2.ID = ID;
c. student2 = student3;
d. student1 = student4;
question
It is an array of structs.
answer
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 of arrays.
c. It is an array of structs.
d. It is a struct.
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[25] = 0;
b. for (int j = 0; j < 25; j++)
applianceList[j].cost = 0;
c. for (int j = 1; j < 25; j++)
applianceList.cost[j] = 0;
d. applianceList.cost = 0;
question
supplierType
answer
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. supplierType
c. struct
d. paintType
question
listType intList;
answer
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 ____________________.
question
rectangleData myRectangle;
answer
Consider the following struct definition:
struct rectangleData
{
double length;
double width;
double area;
double perimeter;
};
Which of the following variable declarations is correct?
a. rectangleData myRectangle;
b. struct rectangleData();
c. rectangle rectangleData;
d. rectangleData rectangle =
new rectangleData();
question
True
answer
T/F? Data in a struct variable must be read one member at a time.
question
reference
answer
If a variable is passed by ____________________, then when the formal parameter changes, the actual parameter also changes.
question
.(dot)
answer
In C++, the ____ symbol is an operator, called the member access operator.
question
False
answer
T/F?
In structs, you access a component by using the struct name together with the relative position of the component.
question
declare
answer
Memory is allocated for struct variables only when you ____________________ them.
question
False
answer
T/F?
Relational operations can be used on struct variables.
question
members
answer
The components of a struct are called the ____ of the struct.
question
five
answer
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
.memberName
answer
The syntax for accessing a struct member is structVariableName____.
question
member-wise
answer
To compare struct variables, you compare them ____.
question
before the definitions of all the functions
answer
Typically, in a program, a struct is defined ____ in the program.
question
Parameter passing by reference
answer
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
Assignment
answer
Which of the following is an allowable aggregate operation on a struct?
a. Arithmetic
b. Assignment
c. Input/output
d. Comparison
question
struct studentType
{
int ID;
};
answer
Which of the following struct definitions is correct in C++?
a. struct studentType
{
int ID = 1;
};
b. struct studentType
{
int ID;
};
c. int struct studentType
{
ID;
}
d. struct studentType
{
string name;
int ID;
double gpa;
}
question
the same
answer
You can assign the value of one struct variable to another struct variable of ____ type.
question
True
answer
T/F?
You can declare struct variables when you define a struct.
question
True
answer
T/F?
You can use an assignment statement to copy the contents of one struct into another struct of the same type.
question
True
answer
T/F?
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).
Haven't found what you need?
Search for quizzes and test answers now
Quizzes.studymoose.com uses cookies. By continuing you agree to our cookie policy