enum data type

my doubt is a general C doubt.. we know if we are using enum the variables which we declare inside automatically increments by one than the previous variable.. but is there any method by which we could make the variables to decrement by one instead of incrementing...

Example

enum my_enum
{ var1=90, var2,var3
};

for this code var2 and var3 will be 91 & 92 respectively, is there any method (possible) to get them 89 & 88...
It was asked in an interview.. any one knows the answer..?

Parents
  • No, there isn't!

    "my doubt is a general C doubt"

    So you should look for your answer in a general 'C' textbook - or even the 'C' standard itself:

    "Each subsequent enumerator with no '=' defines its enumeration constant as the value of the constant expression obtained by adding 1 to the value of the previous enumeration constant"

Reply
  • No, there isn't!

    "my doubt is a general C doubt"

    So you should look for your answer in a general 'C' textbook - or even the 'C' standard itself:

    "Each subsequent enumerator with no '=' defines its enumeration constant as the value of the constant expression obtained by adding 1 to the value of the previous enumeration constant"

Children
More questions in this forum