Sams Teach Yourself C in 21 Days

(singke) #1
Answers 857

F


Answers for Day 11

Quiz


  1. The data items in an array must all be of the same type. A structure can contain
    data items of different types.

  2. The structure member operator is a period. It is used to access members of a struc-
    ture.
    3.struct

  3. A structure tag is tied to a template of a structure and is not an actual variable. A
    structure instance is an allocated structure that can hold data.

  4. These statements define a structure and declare an instance called myaddress. This
    instance is then initialized. The structure member myaddress.nameis initialized to
    the string “Bradley Jones”,yaddress.add1is initialized to “RTSoftware”,myad-
    dress.add2is initialized to “P.O. Box 1213”,myaddress.cityis initialized to
    “Carmel”,myaddress.stateis initialized to “IN”, andmyaddress.zipis initial-
    ized to “46032-1213”.
    6.word myWord;

  5. The following statement changes ptrto point to the second array element:
    ptr++;


Exercises


  1. The code is as follows:
    struct time {
    int hours;
    int minutes;
    int seconds;
    } ;

  2. The code is as follows:
    struct data {
    int value1;
    float value2;
    float value3;


} info ;
3.info.value1 = 100;


  1. The code is as follows:
    struct data *ptr;
    ptr = &info;


49 448201x-APP F 8/13/02 11:22 AM Page 857

Free download pdf