0% found this document useful (0 votes)
9 views4 pages

Enumeration S

Uploaded by

shahzaibmr15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Enumeration S

Uploaded by

shahzaibmr15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ENUMERATIONS

Ikram Ullah
Assistant Professor
(Computer Science)
Enumerations

▪ A program mer-defined type that is lim ited to a fixed list of values.

▪ Less cruicial than structures but can sim plyfy and clarify program s

▪ Syntax

enum enum_name {list of values}


▪ enum : It is keyword. In c language it is m ust in C++ it is optional

▪ enum _name: It is the nam e of enum eration. It can be any user-defined nam e

▪ List of values: These are com ma separated list of values that can be assigned to enum erator. These are
also called as enum erators.

▪ Each value is assigned an integer starting from 0;

▪ In m ost cases, enum erators them selves don't hold values; rather, they serve as sym bolic nam es for
integer constants.
Enumerations

▪ Exam ple

enum Days{Sun, Mon, Tue, Wed, Thu, Fri, Sat}; //Each value is assigned an index starting from 0

void m ain()

Days Val1, Val2; OUTPUT


Val1=Sun;
05
Val2=Fri;

cout<<Val1<<Val2;

▪ Values are not printed rather corresponding integers

▪ sdfsdjf
Enumerations

▪ All values are called as enum erators.

▪ Each enum erator is assigned an integer value starting from 0

▪ Hence we can use these enum erators in arithm etic operations.

▪ Like:

Val2- Val1 // it will give 5 as output


OUTPUT

05

You might also like