Answer T12
/* declare the enums */
typedef enum {hot, cold} cupStyle;
typedef enum {ml, oz} units;
/* declare the Cup type */
typedef struct
{
cupStyle style;
units measure;
int capacity;
} Cup;
void printCup( Cup *cup )
{
char *stylestring, *unitstring;
if ( cup->style == hot ) stylestring = "hot cup";
else stylestring = "cold cup";
if ( cup->measure == ml ) unitstring = "ml";
else unitstring = "oz";
printf("%3d %s %s\n", cup->capacity, unitstring, stylestring );
}
int main()
{
/* declare and initialize two Cups */
Cup cupA = {hot, oz, 12}, cupB = {cold, ml, 16};
/* print values of both Bulbs */
printCup( &cupA );
printCup( &cupB );
return 0;
}