Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, March 10, 2015

What is enum datat type ?

The enum is a user defined data type. It is used to give you an opportunity to invent your own data type and defines what values of the variable of this data type can take.
In other word it is used to declare variables or identifiers that can have only one of the values enclosed within the braces. The values that are enclosed within the braces are known as enumeration constants.
Syntax:
                enum variable {value, value1, value2};
Ex:
enum week{ Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};

Program:
#include <stdio.h>
#include<conio.h>
enum week{ Sunday = 1, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};
void main()
{
enum week today;
today=friday;
printf("Day = %d",today);
getch();
}

Output: Day = 6

No comments:

Post a Comment