BTE320 Chapter 9

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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; };

5

The syntax for accessing a struct member is structVariableName____. a. .memberName b. *memberName c. [memberName] d. $memberName

a. .memberName

A function can return a value of the type struct. a. True b. False

a. True

Data in a struct variable must be read one member at a time. a. True b. False

a. True

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). a. True b. False

a. True

You can declare struct variables when you define a struct. a. True b. False

a. True

You can use an assignment statement to copy the contents of one struct into another struct of the same type. a. True b. False

a. True

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; };

a. struct studentType { int ID; };

In C++, the ____ symbol is an operator, called the member access operator. a. :(colon) b. .(dot) c. ,(comma) d. $ (dollar sign)

b. .(dot)

Which of the following is an allowable aggregate operation on a struct? a. Arithmetic b. Assignment c. Input/output d. Comparison

b. Assignment

A function can return a value of the type array. a. True b. False

b. False

Aggregate input/output operations are allowed on a struct variable. a. True b. False

b. False

In structs, you access a component by using the struct name together with the relative position of the component. a. True b. False

b. False

Relational operations can be used on struct variables. a. True b. False

b. False

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

b. before the definitions of all the functions

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

b. bigRect.length = 10;

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;

b. cin >> bigRect.length;

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;

b. cout << bigRect.length;

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;

b. person2 = person1;

An array name and index are separated using ____. a. curly brackets b. square brackets c. a dot d. a comma

b. square brackets

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

b. the same

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.

c. It is an array of structs.

A struct is typically a ____ data structure. a. simple b. dynamic c. heterogeneous d. linked

c. heterogeneous

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

c. list

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. rectangleData myRectangle;

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

c. supplierType

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

d. Parameter passing by reference

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;

d. cin >> circle.radius;

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

d. either by value or by reference

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;

d. for (int j = 0; j < 25; j++) applianceList.cost[j] = 0;

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)

d. if (bigRect.length == smallRect.width)

To compare struct variables, you compare them ____. a. by reference b. by value c. index-wise d. member-wise

d. member-wise

The components of a struct are called the ____ of the struct. a. variables b. identifiers c. elements d. members

d. members

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;

d. student1.ID = student3.ID

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

d. the values and the length

Memory is allocated for struct variables only when you ____________________ them.

declare

A struct is a(n) ____________________, not a declaration.

definition

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 ____________________.

listType intList

Arrays are passed by ____________________ only.

reference

If a variable is passed by ____________________, then when the formal parameter changes, the actual parameter also changes.

reference


Set pelajaran terkait

Mental Health Chapter 13 Individual Therapies and Nursing Interventions

View Set

Gero Chapter 25: Loss, Death, and Palliative Care

View Set

World History 2 Final Exam Review

View Set

Intro to Marketing Chapter 1 Marketing: Creating and Capturing Customer Value/ Creating Customer Value and Engagement

View Set

human geography agriculture repeat questions

View Set