Notes Enumeration
Notes Enumeration
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.
return 0;
}
The enum names available in an enum type can have the same value.
Ex:
#include <stdio.h>
enum status{success, fail};
enum boolen{fail,pass};
int main(void)
{
printf("The value of success is %d", success);
return 0;
}
Output: Error
In enumeration, we can define an enumerated data type without the name also.
#include <stdio.h>
enum {success, fail} status;
int main(void)
{
status=success;
printf("The value of status is %d", status);
return 0;
}
Typdef:
The typedef is a keyword used in C programming to provide some meaningful names to the
already existing variable in the C program. It behaves similarly as we define the alias for the
commands. In short, we can say that this keyword is used to redefine the name of an already
existing variable.
Syntax of typedef
In the above statements, we have declared the unit variable of type unsigned int by using a
typedef keyword.
Now, we can create the variables of type unsigned int by writing the following statement:
Ex: int main()