Structures

NOTES
    *  You can create arrays of structs.
    * Structs can be copied or assigned.
    * The & operator may be used with structs to show addresses.
    * Structs can be passed into functions. Structs can also be returned from functions.
    * Structs cannot be compared!
  1. 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.
  2. T/F: A structure may be declared globally or locally.
  3. T/F: Structures and arrays are homogenous.
  4. 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.
  5. 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.	.
    
  6. ____ 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;
    
  7. 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
    
  8. 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};
    
  9. 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
    
  10. 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);
    
  11. Create a structure to record the items on your Drivers' license.
  12. What is the difference between struct and typedef?
  13. When passing a struct to a function, is it pass by reference or pass by value? What does that mean?
  14. 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;
    
  15. 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;
    
  16. Create an array of 12 Date structures, one for the first day of each month in the year.