What is enumerated data type?

Showing Answers 1 - 9 of 9 Answers

An enumerated data type is a data type that groups together a set of values and orders them sequentially from 1 to n. You declare an enumerated type when you want a variable to hold only a limited number of distinct values. For example, you can define an enumerated type named colors whose legal values are "red" and "green" and "yellow". Examples type COLOR is enum red green // red = 1, green = 2 type YESNO is enum NO = 0 YES // NO = 0, YES = 1

  Was this answer useful?  Yes

testingeek

  • Jan 25th, 2008
 

 enumerated type is an abstract data type used to model an attribute that has a specific number of options (or identifiers) .
Eg :
enum cardsuit {
   CLUBS,
   DIAMONDS,
   HEARTS,
   SPADES
};

However at runtime the the enum will be implemented with an interger.
eg :
enum cardsuit {
   CLUBS    = 1,
   DIAMONDS = 2,
   HEARTS   = 4,
   SPADES   = 8
};

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions