C Sample File : Enumeration
Enumeration :
// Program To Demonstrate Enum
Types
#include<stdio.h>
#include<conio.h>
enum
days{sun,mon,tue,wed,thu,fri,sat};
void main()
{
days day1,day2;
int res;
clrscr();
day1=mon;
// Assigning Values
day2=sat;
res=day2-day1; //Can
Do Integer Arithmetic
printf("Days Between Mon & Sat Are
: %d\n",res);
if(day1<day2) // Can Do
Comparisons
{
printf("\nMon Comes Before Sat
!!!");
}
getch();
}
Output :
Days
Between Mon & Sat Are : 5
Mon
Comes Before Sat !!!
Comments
Post a Comment