+ 2
Can anyone help me to understand this code?
#include<stdio.h> enum { CODE = 4, BUG = 49, FEATURE }; int main() { printf("%d", FEATURE); } The answers is 50. how the answere is 50? I found this in C challenges.
4 Answers
+ 7
If you don't assign a numerical value to a constant identifier inside an enum, the compiler will automatically assign it the value of the previous identifier + 1. In case the very first identifier has no value, it will be 0. Since BUG is assigned 49, FEATURE automatically becomes 50. I'd suggest looking up enumerations for more information on this data type.
+ 3
To understand this question you need to have knowledge about enumerations and know how they work. Enumerations are nothing but a user defined data type which consists of some constant values. When ever you assign a value to the variable in enumeration the succeeding value will be more by one. Since BUG=49 it's successor 'FEATURE' will be 50.
+ 2
To understand that question, you've to have knowledge of enumeration.