

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Enums
incomplete
2: Non-Default Values
incomplete
3: Switch Case
incomplete
4: Sizeof Enum
incomplete
This lesson's interactive features are locked, please to keep using them
The same sizeof operator that we've talked about works on enums.
Generally, enums in C are the same size as an int. However, if an enum value exceeds the range of an int, the C compiler will use a larger integer type to accommodate the value, such as an unsigned int or a long.
unsigned int doesn't represent negative numbers, so it can represent larger positive numbers.long is just a larger integer type than int, so it can represent larger numbers.Enums are often used to represent the possibilities in a set. For example:
SMALL = 0MEDIUM = 1LARGE = 2EXTRA_LARGE = 3Your code probably cares a lot about which size a variable represents, but it probably doesn't care that SMALL happens to be 0 under the hood. From the compiler's perspective, enums are just fancy integers.
At the start of main(), print the size of the two enums already defined for you, in the format:
The size of BigNumbers is Y bytes
The size of HttpErrorCode is X bytes
Remember that %zu is the format specifier for size_t.