Multiple choice

penny = one nickel = five dime = ten quarter = twenty-five

How is enum used to define the values of the American coins listed above?

  1. enum coin {(penny,1), (nickel,5), (dime,10), (quarter,25)};

  2. enum coin ({penny,1}, {nickel,5}, {dime,10}, {quarter,25});

  3. enum coin {penny=1,nickel=5,dime=10,quarter=25};

  4. enum coin (penny=1,nickel=5,dime=10,quarter=25);

  5. enum coin {penny, nickel, dime, quarter} (1, 5, 10, 25);

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In C, enum constants are defined using curly braces with name=value pairs separated by commas. Option C shows the correct syntax: enum coin {penny=1,nickel=5,dime=10,quarter=25};. Options A, B, D, E use incorrect syntax with parentheses or wrong bracket types.