home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
ctutor2.zip
/
ANSWERS
/
CH11_2.C
< prev
next >
Wrap
Text File
|
1989-11-10
|
1KB
|
53 lines
main()
{
struct {
char what[25];
int legs,arms;
} object[6], *point;
int index;
strcpy(object[0].what,"human being");
object[0].legs = 2;
object[0].arms = 2;
strcpy(object[1].what,"dog");
object[1].legs = 4;
object[1].arms = 0;
strcpy(object[2].what,"television set");
object[2].legs = 4;
object[2].arms = 0;
strcpy(object[3].what,"chair");
object[3].legs = 4;
object[3].arms = 2;
strcpy(object[4].what,"centipede");
object[4].legs = 100;
object[4].arms = 0;
strcpy(object[5].what,"spider");
object[5].legs = 6;
object[5].arms = 0;
point = object;
for(index = 0;index < 6;index++) {
printf("A %s has %d legs and %d arms.\n", point->what,
point->legs, point->arms);
point++;
}
}
/* Result of execution
A human being has 2 legs and 2 arms.
A dog has 4 legs and 0 arms.
A television set has 4 legs and 0 arms.
A chair has 4 legs and 2 arms.
A centipede has 100 legs and 0 arms.
A spider has 6 legs and 0 arms.
*/