codegurukool.com · Free coding tutorials & online compiler

Home › C Tutorial › C enums

C enums

Named integer constants.

enum assigns names to numbers starting at 0 unless you set values.

Example code

#include <stdio.h>
enum Level { LOW, MEDIUM = 5, HIGH };
int main() {
  enum Level l = HIGH;
  printf("%d %d\n", LOW, l);
  return 0;
}

Run this code in the online editor

← C struct paddingC allocate and access memory →