Computer Science, asked by Saadhvi447, 1 year ago

Describe with examples the uses of enumeration data types

Answers

Answered by Quillll
1
Enumerated Data Types: The Enumerated data type allows the programmer to invent his own data type and decide what value the variables of this data type may carry. Enum or enumerator is an integer or number with defined meaningful names. Enum is often used inside C programs to replace a hard coded numbers with some meaningful symbols

ex.
/* A function prints state of a task with numbers */ void print_task_state (int state) { switch (state) { csase 0: printf ("Task has been added.\n"); break; case 1: printf("Task is ready.\n"); break; case 2: printf("Task is running.\n"); break; case 3: printf("Task is waiting.\n"); break; case 4: printf("Task has been terminated.\n"); break; default: printf("Task in undefined state.\n"); } }

Answered by TwinkleTwinkle11111
0
Enumeretated type is a user defined data type used in computer programmingto map a set of names to numeric values. Enumerated data type variable can only have values that are previously declared.In other words they work with a finite list of values.
Similar questions