Enumerations (Enums)
Enums allow you to define a set of named constants, representing a group of related values. They provide a convenient way to work with a fixed set of values and improve code readability.
#include <stdio.h>
enum Day {
MON,
TUE,
WED,
THU,
FRI,
SAT,
SUN
};
int main() {
enum Day today = WED;
if (today == WED || today == THU) {
printf("It's a weekday.\n");
} else {
printf("It's a weekend.\n");
}
return 0;
}
No comments:
Post a Comment