Puzzle T12

Beverage Cup

Define a struct type, using typedef, for a beverage cup. Cups may be intended for hot or cold beverages, and contain an integer number of fluid ounces or milliliters.

Use an enum with a typedef for the hot/cold member and for the oz/ml member. If you don't know enum, use older-style #define or integer constants.

/* declare the enums */

/* declare the Cup type */

/* function to print a Cup */
void printCup( Cup *cup ) {...}

int main()
{
  /* declare and initialize two Cups */
  Cup cupA, cupB;

  /* print values of both Cups */
  printCup( cupA );
  printCup( cupA );
    
  return 0;
} 


Answer         Next Page         Previous Page Home