Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enum example in C program.
#include <stdio.h>
int main()
{
enum weekdays{sun, mon, tue, wed, thu=121, fri, sat};
enum weekdays sunday = sun;
enum weekdays friday = fri;
printf("sunday has the value: %d and friday: %d", sunday, friday);//Here friday has the value 122 because the previous const thu has the value of 121 whilst wed has the value of 3 because sun is initialized to zero.
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.