Structured Data Verified Test Bank Ch.11 - Test Bank | C++ Control Structures 9e by Tony Gaddis. DOCX document preview.

Structured Data Verified Test Bank Ch.11

Starting Out with C++ from Control Structures to Objects, 9e (Gaddis)

Chapter 11 Structured Data

TRUE/FALSE

1. A struct can contain members with varying data types.

2. Any mathematical operation that can be performed on regular C++ variables can be performed on structure members.

3. Structure variables may be passed as arguments to functions.

4. The structure pointer operator is used to dereference a pointer to a structure, not a pointer that is a member of a structure.

5. If a function is legally prototyped to return an integer value, it can return a structure member that is an integer data type.

6. A function cannot modify the members of a structure.

7. The expression s->m; indicates that s is a structure pointer and m is a structure member.

8. It is possible to output the contents of all members of a structure variable using a cout << statement followed by the name of the structure variable.

9. When a programmer creates an abstract data type, he or she can decide what values are acceptable for the data type, as well as what operations may be performed on the data type.

10. It is possible for a structure variable to be a member of another structure variable.

11. The expression *s->p; indicates that s is a structure pointer and p, which is also a pointer, is a member of the structure pointed to by s.

12. It is possible for a structure to contain, as a member, a pointer to its own structure type.

13. You cannot directly assign an integer value to an enum variable.

14. You cannot directly assign an enumerator to an int variable.

15. When you use a strongly typed enumerator in C++11 you must prefix the enumerator with the name of the enum followed by the :: operator.

16. The names of enumerators in an enumerated data type must be enclosed in quotation marks.

17. In C++11 if you want to retrieve a strongly typed enumerator's underlying integer value, you must use a cast operator.

18. Given the structure definition shown, assume that circle1 and circle2 are variables of the Circle type and their members have been initialized.

struct Circle

{

double centerX;

double centerY;

double radius;

};

Then, is it true or false that the following statement correctly determines whether the two variables' members contain the same data?

if (circle1 == circle2)

MULTIPLE CHOICE

1. Which of the following describes only the general characteristics of an object?

a.

initialization

b.

abstraction

c.

detailed specification

d.

initiation

e.

None of these

2. Which of the following is required after the closing brace of the structure definition?

a.

square bracket

b.

period

c.

semicolon

d.

colon

e.

None of these

3. Which of the following is an example of a C++ primitive data type?

a.

unsigned short int

b.

long double

c.

unsigned char

d.

All of these

e.

None of these

4. The following statement __________.

bookList[2].publisher[3] = 't';

a.

is illegal in C++

b.

will change the name of the second book in bookList to 't'

c.

will store the character 't' in the fourth element of the publisher member of bookList[2]

d.

will result in a runtime error

e.

None of these

5. When a structure is passed __________ to a function, its members are not copied.

a.

by reference

b.

by value

c.

Either of these

d.

Neither of these

6. Passing a structure as a constant reference parameter to a function

a.

can potentially result in changes to the structure's members

b.

guarantees not to result in changes to the structure's members

c.

will always change the structure's members

d.

None of these

7. You may use a pointer to a structure as a

a.

function parameter

b.

structure member

c.

function return type

d.

All of these

e.

None of these

8. Data types that are created by the programmer are known as

a.

variables

b.

abstract data types (ADTs)

c.

functions

d.

parameters

e.

None of these

9. Before a structure can be used it must be

a.

declared

b.

dereferenced

c.

initialized

d.

All of these

e.

None of these

10. The name of a structure is referred to as its

a.

data type

b.

argument

c.

parameter

d.

tag

e.

None of these

11. A function __________ return a structure.

a.

may

b.

may not

c.

will always

d.

can never

e.

None of these

12. A structure pointer contains

a.

the address of a structure variable

b.

the dereferenced address of a structure tag

c.

the name and address of the structure tag

d.

the address of a structure tag

e.

None of these

13. Which of the following assigns a value to the hourlyWage member of employee[2]?

a.

employee[2] -> hourlyWage = 50.00;

b.

employee2.hourlyWage = 7.50;

c.

hourlyWage[2].employee = 29.75;

d.

employee[2].hourlyWage = 75.00;

e.

None of these

14. If Circle is a structure tag, then the following statement can be the header line for a function that __________.

Circle doSomething(Circle c2)

a.

determines and returns the area of a circle

b.

takes a Circle structure as a parameter, does something, and returns a Circle structure

c.

operates on a constant reference to a Circle structure

d.

takes two Circle parameters and does something

e.

None of these

15. Which of the following will allow you to access structure members?

a.

the structure access operator

b.

the dot operator

c.

the #include<structaccess> directive

d.

the getmember function

e.

None of these

16. To dereference a structure pointer, the appropriate operator is

a.

the ampersand (&)

b.

an asterisk (*)

c.

the -> operator

d.

the <- operator (<-)

e.

None of these

17. If a is a structure variable and p, a pointer, is a member of the structure, what will the following statement do?

cout << *a.p;

a.

output the dereferenced value pointed to by p

b.

result in a compiler error

c.

output the address stored in p

d.

output the value stored in a

e.

None of these

18. A structure __________ contain members of the same data type.

a.

cannot

b.

can

c.

shouldn't

d.

None of these

19. Which of the following statements outputs the value of the gpa member of element [1] of the student array?

a.

cout << student1.gpa;

b.

cout << firstStudent.gpa;

c.

cout << student[1].gpa;

d.

cout << student1->gpa;

e.

None of these

20. If Circle is a structure, what does the following statement do?

Circle *pcirc = nullptr;

a.

It declares an empty structure variable named *pcirc.

b.

It declares a structure pointer called pcirc initialized with a null pointer.

c.

The statement is illegal in C++.

d.

It initializes a null pointer with the value of the Circle pointer.

e.

None of these

21. A good reason to pass a structure as a constant reference is

a.

to prevent changes to the structure's members

b.

to ensure changes to the structure's members

c.

to slow down the function's execution which helps prevent errors

d.

to speed up the function's modification of the structure's members

e.

None of these

22. With an enumerated data type, the enumerators are stored in memory as

a.

strings

b.

integers

c.

characters

d.

doubles

23. In C++11, you can use a new type of enum known as a(n) __________ (also known as an enum class) to have multiple enumerators with the same name, within the same scope.

a.

universal enum

b.

auto enum

c.

multi-cast enum

d.

strongly typed enum

e.

None of these

24. A declaration for an enumerated type begins with the __________ key word.

a.

enumerated

b.

enum_type

c.

enum

d.

ENUM

e.

None of these

25. After the following statement executes, what value will the MAPLE enumerator be stored as, in memory?

enum Tree { OAK, MAPLE, PINE };

a.

"MAPLE"

b.

2

c.

'M'

d.

1

e.

1.0

26. Given the following decaration:

enum Tree { OAK, MAPLE, PINE };

What is the value of the following relational expression?

OAK > PINE

a.

true

b.

false

c.

This is an error. You cannot compare enumerators with relational operators.

27. Given the following structure decaration, Employee is

struct Employee

{

string name;

int idNum;

};

a.

a member

b.

an array

c.

a tag

d.

None of these

28. Given the following structure decaration, idNum is

struct Employee

{

string name;

int idNum;

};

a.

a member

b.

an array

c.

a tag

d.

None of these

Document Information

Document Type:
DOCX
Chapter Number:
11
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 11 Structured Data
Author:
Tony Gaddis

Connected Book

Test Bank | C++ Control Structures 9e

By Tony Gaddis

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party