- A structure brings together a collection of
- variables of the same data type.
- variables of any data type.
- integers with user-defined names.
- named constants of any type.
- The closing brace of a structure is followed by a ___________
- A structure specification creates or allocates space in memory for a variable.
- True
- False
- A structure variable definition creates or allocates space in memory for a variable.
- True
- False
- When using the dot operator with a structure, the identifier to the left of the dot operator is the name of
- a structure member or field.
- a structure tag.
- a structure variable or object.
- the keyword struct.
- When using the dot operator with a structure, the identifier to the right of the dot operator is the name of
- a structure member or field.
- a structure tag.
- a structure variable or object.
- the keyword struct.
- When using the arrow operator with a structure, the identifier to the left of the arrow operator is the name of
- a structure member.
- a structure tag.
- a pointer to a structure variable or object.
- the keyword struct.
- When using the arrow operator with a structure, the identifier to the right of the arrow operator is the name of
- a structure member.
- a structure tag.
- a pointer to a structure variable or object.
- the keyword struct.
- Examine the following structure specification and variable definition below:
struct foobar
{
int foo;
char bar;
};
. . . .
foobar fb;
Which of the following correctly accesses a field in the structure?
- fb.foo
- fb->foo
- The correct field access is not shown.
- Examine the following structure specification and variable definition below:
struct foobar
{
int foo;
char bar;
};
. . . .
foobar* fb;
// fb is initialized
Which of the following correctly accesses a field in the structure?
- fb.bar
- fb->bar
- The correct field access is not shown.
- Write a structure specification for a structure named Time (remember that C++ is case sensitive) that includes three fields of type int - called hours, minutes, and seconds.
- Write a statement that defines an automatic variable named time2 and whose type is a Time structure.
- Write a statement that sets the hours member of the automatic time2 structure variable equal to 11 without changing the values stored in minutes and seconds.
- You can assign one structure variable to another, provided they are of the same structure type.
- True
- False
- Modern enumerations can contain objects, but the older, basic or traditional enumerations are collections of
- variables of different data types.
- related data variables.
- integers with user-defined names.
- floating point numbers with user-defined names.
- Unless a programmer explicitly sets different values, the first three enumerators or elements of an enum normally represent the values __________, _________, and _________
- Based on the following enumeration, what is the value of ERROR?
enum { READ, WRITE, EXECUTE, ERROR };
- 0
- 1
- 2
- 3
- 4
- 5
- The statement will not compile because a value is not assigned to any names.
- Based on the following enumeration, what is the value of ERROR?
enum { READ = 2, WRITE = 4, EXECUTE = 8, ERROR = 16 };
- 9
- 10
- 11
- 16
- 32
- The statement will not compile because values cannot be assigned to enumerators.
- The statement will not compile because it is missing the enumeration tag.
- Based on the following enumeration, what is the value of ERROR?
enum { READ = 2, WRITE = 4, EXECUTE = 8, ERROR };
- 9
- 10
- 11
- 16
- 32
- The statement will not compile because ERROR is not assigned a value
- The statement will not compile because it is missing the enumeration tag.
- Which of the following is NOT a benefit of symbolic constants?
- Naming constants can provide shorthand names for long values.
- Naming constants can help the program run more efficiently.
- Names can help clarify the meaning or purpose of a value in the program.
- Naming constants can make maintaining or modifying a program easier.
- A program specifies a structure named Foo and defines two automatic Foo variables named x and y. Write the statements needed to swap the values stored in x and y.