C Program to Demonstrate Working of "enum"

In this program, you'll learn the use of enum in C programming language. Enumeration (or enum) is a user defined data type in C. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain. Syntax: enum flag{constant1, constant2, constant3, ....... }; Example: enum year{Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};



Source Code
#include<stdio.h>

int main()
{
    enum WeekDays {Mon, Tue, Wed, Thurs, Fri, Sat, Sun};
    int i;

    for(i = Mon; i <= Fri; i++)
    {
        printf("%d\n", i);
    }
    return 0;
}
Output
0
1
2
3
4





"Coding Hub - Learn to code" app now available on Google Play Store