Data types - Q & A


what is enumerated data type?


Its simple.user defined data type if we talk of C.
Basically you use enum when you know that some variable can have only value from this range,also it makes your program readibilty and understandibilty better.

Lets take an example –

enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun};

int main()
enum week day;
day = Wed;
return 0;

here (enum week is correspondent to int or datatype ,after that its variable name,we have used day,you can use enum week no_of_days),since we have not defined initial value,it will automatically take monday value to be zero and subsequent value be + 1 from there,you can define value from between also like if you give wednesday value = 10 so defintion of enum will be like

enum week{Mon, Tue, Wed=10, Thur, Fri, Sat, Sun};

What will be the output if i print sun?Find it out yourself.You can use online editor to write small c/c++ programs,


In computer programming, an enumerated type is a data type consisting of a set of named values called elements, members, enumeral, or enumerators of the type.


#include< stdio.h>
void main()
int i;
{ printf("\n%d ", i);}
0 1 2 3 4 5 6 7 8 9 10 11

enum is user defined data type.
enum identifier{ enumerator-list }

In the case of enum the first case in the braces will be defaut 0 as in program january is 0


Enumerated type is a user-defined data type used in computer programming to map a set of names to numeric values. Enumerated data type variables can only have values that are previously declared. In other words, they work with a finite list of values.

Enumerated data types help make the code more self-documenting and prevent programmers from writing illogical code on values of enumerators. Enumerated data also hides unnecessary details from programmers


An enumerated data type declaration gives the name of the enumeration tag and defines the set of named integer identifiers. Any variable with enumerated data type stores one of the values of the enumeration set defined by that type.