In C programming, an enumeration or enum is a user-defined data type that consists of a set of named values. The enum keyword is used to declare an enumeration and to define the set of values it contains.
The basic syntax for declaring an enumeration in C is as follows:
enumidentifier
{
value1,
value2,
value3,
. . .
}
Here, the identifier is the name of the enumeration and the value1, value2, value3, etc. are the named values that it contains. Each value is separated by a comma and the list of values is enclosed in curly braces {}.
Here is an example of an enumeration being used in a program:
This program demonstrates how to declare and use enumerations in C, how to assign values to enumeration members and how to use enumeration variables in the program.
//enumeration or enum in c #include<stdio.h> enum Bool{No=10,Yes=20}; int main() { enum point {x=25,y}; enum Bool a; enum point b; a=Yes; b=y; printf("\na : %d",a); printf("\nb : %d",b); return 0; }To download raw file Click Here
a : 20 b : 26
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions