Enumerations (Enums)

 Enumerations (Enums)


Enums allow you to define a set of named constants, representing a group of related values. They provide a convenient way to work with a fixed set of values and improve code readability.



#include <stdio.h>


enum Day {

    MON,

    TUE,

    WED,

    THU,

    FRI,

    SAT,

    SUN

};


int main() {

    enum Day today = WED;


    if (today == WED || today == THU) {

        printf("It's a weekday.\n");

    } else {

        printf("It's a weekend.\n");

    }


    return 0;

}

No comments:

Post a Comment

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...