You are on page 1of 14

4/6/23, 5:00 PM Structures

Structures

1. Email *

2. You can declare struct variables when you define a struct. 1 point

Mark only one oval.

True

False

3. In structs, you access a component by using the struct name together with the relative position of the 1 point

component

Mark only one oval.

True

False

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 1/14
4/6/23, 5:00 PM Structures

4. To access a structure member (component), you use the struct variable name together with the member 1 point

name; these names are separated by the dot (period) operator.

Mark only one oval.

True

False

5. You can use an assignment statement to copy the contents of one struct variable into another struct variable 1 point
of the same type.

Mark only one oval.

True

False

6. Relational operations can be used on struct variables 1 point

Mark only one oval.

True

False

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 2/14
4/6/23, 5:00 PM Structures

7. Data in a struct variable must be read one member at a time. 1 point

Mark only one oval.

True

False

8. A function can return a value of the type array. 1 point

Mark only one oval.

True

False

9. A function can return a value of the type struct. 1 point

Mark only one oval.

True

False

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 3/14
4/6/23, 5:00 PM Structures

10. Aggregate input/output operations are allowed on a struct variable. 1 point

Mark only one oval.

True

False

11. A struct is typically a ____ data structure. 1 point

Mark only one oval.

simple

homogenous

heterogeneous

multi

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 4/14
4/6/23, 5:00 PM Structures

12. The components of a struct are called the ____ of the struct. 1 point

Mark only one oval.

variables

identifiers

elements

members

13. Which of the following struct definitions is correct in C++? 1 point

Mark only one oval.

struct studentType { int ID; };

struct studentType { string name; int ID; double gpa; }

int struct studentType { int ID; }

struct studentType { ID; };

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 5/14
4/6/23, 5:00 PM Structures

14. Consider the following struct definition: 1 point


struct rectangleData
{
 double length;
 double width;
 double area;
double perimeter;
 };
Which of the following variable declarations is correct?  

Mark only one oval.

rectangle rectangleData;

struct rectangleData();

rectangleData myRectangle;

rectangleData rectangle.length;

15. Typically, in a program, a struct is defined ____ in the program. 1 point

Mark only one oval.

in the main function

before the definitions of all the functions

after the definitions of all the functions

in any function

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 6/14
4/6/23, 5:00 PM Structures

16. An array name and its index are separated using ____. 1 point

Mark only one oval.

curly braces

square brackets

a dot

a comma

17.  The syntax for accessing a struct member is structVariableName____. 1 point

Mark only one oval.

.memberName

*memberName

[memberName]

$memberName

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 7/14
4/6/23, 5:00 PM Structures

18. Consider the following statements: 1 point


struct rectangleData { double length; double width; double area; double perimeter; };
rectangleData bigRect; 

Which of the following statements correctly initializes the member length of bigRect? 

Mark only one oval.

bigRect = {10};

bigRect.length = 10;

length[0]= 10;

bigRect[0]= 10

19. In C++, the ____ symbol is an operator, called the member access operator. 0 points

Mark only one oval.

:(colon)

.(dot)

,(comma)

$ (dollar sign)

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 8/14
4/6/23, 5:00 PM Structures

20. Consider the following statements: 0 points


struct rectangleData { double length; double width; double area; double perimeter; };

rectangleData bigRect;

Which of the following statements is valid in C++?

Mark only one oval.

cin >> bigRect;

cin >> bigRect.length;

perimeter = 2 * (length + width);

area = length * width;

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 9/14
4/6/23, 5:00 PM Structures

21. 20. Consider the following statements: struct personalInfo { string name; int age; double height; double 1 point

weight; }; struct commonInfo { string name; int age; };

personalInfo person1, person2;


commonInfo person3, person4;

Which of the following statements is valid in C++?

Mark only one oval.

person1 = person3;

person2 = person1;

person2 = person3;

person2 = person4;

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

23. Consider the following struct definition: ​const int ARRAY_SIZE = 1000; ​struct listType { int 1 point
listElem[ARRAY_SIZE]; int listLength; }; ​
The statement that declares intList to be a struct variable of type listType is ____________________.

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 10/14
4/6/23, 5:00 PM Structures

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

25. The following statement defines a struct houseType with a total of ____________________ member(s). 1 point
struct houseType { string style; int numOfBedrooms; int numOfBathrooms; int numOfCarsGarage; int
yearBuilt; };

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

27. Consider the following statements: struct supplierType { string name; int supplierID; }; struct paintType { 1 point
supplierType supplier; string color; string paintID; }; paintType paint; What is the data type of paint.supplier?

Mark only one oval.

string

paintType

supplierType

struct

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 11/14
4/6/23, 5:00 PM Structures

28. Consider the following statements: struct supplierType { string name; int supplierID; }; struct applianceType { 1 point
supplierType supplier; string modelNo; double cost; }; applianceType applianceList[25]; Which of the
following statements correctly initialize the cost of each applianceList element to 0?

Mark only one oval.

applianceList.cost = 0;

applianceList.cost[25] = 0;

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

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

29. A list has two items associated with it: ____. 1 point

Mark only one oval.

the length and the references

the values and the references

the indexes and the length

the values and the length

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 12/14
4/6/23, 5:00 PM Structures

30. Which of the following is an allowable aggregate operation on struct variables? 1 point

Mark only one oval.

Arithmetic

Assignment

Input/output

Comparison

This content is neither created nor endorsed by Google.

 Forms

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 13/14
4/6/23, 5:00 PM Structures

https://docs.google.com/forms/d/19zZZhWB7eIPmOSc12wko9mzVnRr7KhfHPhqgK8uP9aA/edit 14/14

You might also like