This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/Exercises/C19/enum_example.c

22 lines
464 B
C
Raw Permalink Normal View History

2022-04-08 15:12:38 +00:00
#include <stdio.h>
#include <stdlib.h>
enum DOW { sun, mon, tue, wed, thu, fri, sat } ;
// Main () - execution starts here
int main (void)
{
enum DOW day;
/* Code that get a value for 'day' */
day = tue;
switch (day)
{
case sun : printf ("Sunday\n") ; break ;
case mon : printf ("Monday\n") ; break ;
case tue : printf ("Tuesday\n") ; break ;
/* etc. */
}
return (0); // Exit indicating success
}