Question: Exercise 1 0 . 0 TASK: Declare an enumerated type ( enum ) that can hold the values of each state required to implement the

Exercise 10.0
TASK: Declare an enumerated type (enum) that can hold the values of each state required to implement the state machine in "state_machine_tut10.png".
Use meaningful names for each enum value.
TIP: Use the "typedef" keyword to create a type alias for your enum.
Use the name of each state for the corresponding enum value
Enumerated types
An enumerated type or enum in C allows you to declare a new type which has a finite number of defined values
The syntax for declaring a new enum type is:
enum idetifier {
VALUEO,
VALUE1,
VALUEO
As with structs and unions, anonymous enums can be declared.
Enums are treated internally by the compiler as integers (by default the first element is assigned the value 0, then 1 for the next etc.), but you should never rely on this fact
Example enum declaration and use
typedef enum { RED, GREEN, BLUE
} colour;
colour my_colour = RED;
int main(){
If (my_colour == RED){
printf("My colour is red. }
(2;
CRICOS No.002131
 Exercise 10.0 TASK: Declare an enumerated type (enum) that can hold

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!