- T/F: When defining structures, if the form of the structure is not followed by any variable names, the list of structure members must be preceded by a user-selected structure type name.
- T/F: A structure may be declared globally or locally.
- T/F: Structures and arrays are homogenous.
- T/F: When passing a structure to a function, the calling function and the called function must both refer to the same globally defined structure type.
- Each member of a structure is accessed by giving both the structure name and individual data item name, separated by a ____.
a. @ c. :
b. -> d. .
- ____ is not a valid C statement.
a. struct {int month; int day; int year;} birth;
b. struct {int month; int day; int year;} birth, current;
c. struct Date {int month; int day; int year;};
d. struct {int month, int day, int year} birth;
- In the following definition, ____ is the structure type name.
struct Date
{
int month;
int day;
int year;
} birth, current;
a. Date c. birth
b. month d. current
-
After the following declaration, you can define and initialize a variable birth of this structure type as follows ____.
struct Date
{
int month;
int day;
int year;
};
a. Date birth = {12, 28, 1987};
b. struct Date birth = {12, 28, 1987};
c. Date birth = {12; 28; 1987};
d. struct Date birth = {12; 28; 1987};
-
If you have declared a structure named Date, you can then make the name DATE a synonym for the terms struct Date, by using the statement ____.
a. typedef struct Date DATE; c. #define struct Date DATE
b. typedef DATE struct Date; d. #define DATE struct Date
-
The function call ____ passes a copy of the complete emp structure to calcNet().
a. calcNet(struct emp); c. calcNet(&emp);
b. calcNet(*emp); d. calcNet(emp);
- Create a structure to record the items on your Drivers' license.
- What is the difference between struct and typedef?
- When passing a struct to a function, is it pass by reference or pass by value? What does that mean?
- What is the difference between the following three structure declarations:
struct Date
{
int month;
int year;
};
struct
{
int month;
int year;
} Date;
struct Date
{
int month;
int year;
} date;
- Given the following structure, write a function that takes two date structures
and return an integer value designating how many days the first date comes before/after the other
date (negative means the first date parameter comes before the second, zero means they're equal).
struct Date
{
int month;
int year;
} date1, date2;
- Create an array of 12 Date structures, one for the first day of each month in the year.