Constants and enum
const makes values read only. #define makes a macro and enum names integer constants.
Example
#include <stdio.h>
int main(void) {
enum Color { RED, GREEN = 5, BLUE };
const int k = 7;
printf("%d %d %d %d %d\n", 3, RED, GREEN, BLUE, k);
return 0;
}Result
3 0 5 6 7
Exercise
Declare an enum.
Color { RED };Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.