Thursday 25 June 2015

Enumeration concepts in C

  
Definition:
  •          Enumeration is Userdefined Datatype in C.
  •          Keyword: enum
Syntax:

  enum userdefined_name{value1,value2,...};

Sample program:

#include<stdio.h>
#include<conio.h>
void main()
{
enum days{sun,mon,tues,wed,thu,fri,sat};
enum days weekend;                                          //weekend is the instance of days.
weekend=sat;
printf("weekend is %d",weekend);
getch();
}

output:
weekend is 6 //assume sun as 0 ,mon as 1 like that

No comments:

Post a Comment