978-1337102087 Chapter 9

subject Type Homework Help
subject Pages 9
subject Words 1247
subject Authors D. S. Malik

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 1
1. You can declare struct variables when you define a struct.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
614
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
2. In structs, you access a component by using the struct name together with the relative position of the
component.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
614
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
3. 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
ANSWER:
True
POINTS:
1
REFERENCES:
614
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/30/2016 12:48 PM
4. You can use an assignment statement to copy the contents of one struct into another struct of the same type.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
617
QUESTION TYPE:
True / False
HAS VARIABLES:
False
page-pf2
Name:
Class:
Date:
page-pf3
Name:
Class:
Date:
page-pf4
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 4
{
string name;
int ID;
double gpa;
}
c.
int struct studentType
{
ID;
}
d.
struct studentType
{
int ID = 1;
};
ANSWER:
a
POINTS:
1
REFERENCES:
612
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
13. 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();
ANSWER:
c
POINTS:
1
REFERENCES:
613
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
page-pf5
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 5
14. 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
ANSWER:
b
POINTS:
1
REFERENCES:
614
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
15. An array name and index are separated using ____.
a.
curly brackets
b.
square brackets
c.
a dot
d.
a comma
ANSWER:
b
POINTS:
1
REFERENCES:
614
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
16. The syntax for accessing a struct member is structVariableName____.
a.
.memberName
b.
*memberName
c.
[memberName]
d.
$memberName
ANSWER:
a
POINTS:
1
REFERENCES:
614
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
17. Consider the following statements:
struct rectangleData
{
double length;
double width;
double area;
page-pf6
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 6
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
ANSWER:
b
POINTS:
1
REFERENCES:
615
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
18. In C++, the ____ symbol is an operator, called the member access operator.
a.
:(colon)
b.
.(dot)
c.
,(comma)
d.
$ (dollar sign)
ANSWER:
b
POINTS:
1
REFERENCES:
614
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
19. 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;
page-pf7
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 7
ANSWER:
b
POINTS:
1
REFERENCES:
615
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
20. 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;
ANSWER:
b
POINTS:
1
REFERENCES:
617
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
21. Consider the following statements:
struct studentType1
{
string name;
int ID;
double gpa;
page-pf8
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 8
};
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;
ANSWER:
d
POINTS:
1
REFERENCES:
618
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
22. 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
ANSWER:
b
POINTS:
1
REFERENCES:
617
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
23. To compare struct variables, you compare them ____.
a.
by reference
b.
by value
c.
index-wise
d.
member-wise
ANSWER:
d
POINTS:
1
REFERENCES:
618
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
page-pf9
Name:
Class:
Date:
page-pfa
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 10
c.
cin >> circle;
d.
cin >> circle.radius;
ANSWER:
d
POINTS:
1
REFERENCES:
619
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
26. 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;
ANSWER:
b
POINTS:
1
REFERENCES:
619
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
27. 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
ANSWER:
d
POINTS:
1
REFERENCES:
619
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
page-pfb
Name:
Class:
Date:
page-pfc
Name:
Class:
Date:
page-pfd
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 13
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;
ANSWER:
d
POINTS:
1
REFERENCES:
624
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:40 PM
DATE MODIFIED:
10/5/2016 1:40 PM
34. 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
ANSWER:
c
POINTS:
1
REFERENCES:
626
page-pfe
Name:
Class:
Date:
page-pff
Name:
Class:
Date:

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.