An enum defines a set of named integer constants, making code easier to read.
enum Level { LOW, MEDIUM, HIGH };: LOW is 0, MEDIUM 1, HIGH 2. You can assign your own values too.
Named integer constants.
✍️ 2 exercises in this lessonAn enum defines a set of named integer constants, making code easier to read.
enum Level { LOW, MEDIUM, HIGH };: LOW is 0, MEDIUM 1, HIGH 2. You can assign your own values too.
Mastering C Enums helps you write clean and reliable C code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
#include <stdio.h>
enum Status { PENDING = 1, SHIPPED, DELIVERED };
int main() {
enum Status order = SHIPPED;
printf("Status code: %d\n", order);
if (order == SHIPPED) {
printf("Your order is on the way\n");
}
return 0;
}
Status code: 2 Your order is on the way
Check what you learned in “C Enums”.
Declare an enum.
Level { LOW, MEDIUM, HIGH };
In enum Level { LOW, MEDIUM, HIGH }, what is MEDIUM?
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services