Explain what an enumerated type isSolutionEnum is also calle

Explain what an enumerated type is?

Solution

Enum is also called enumerated Data type

Enum is a user defined data type

Syntax: of enumerated data type

Enum is a data type which contains fixed set of constants

identifier is a user defined datatype variable name

val1,val2,val3.....valn is a set of enum values

enum is just used for generation index values.

index starts from 0 to n

example

solution.cpp

#include<iostream>//header for input output function
using namespace std;//it tells the compiler to link std namespace
int main()
{//main function
int i;
enum season {winter,summer,spring,fall};//enum data type
for(i=winter;i<=fall;i++)//for loop
      cout<<i<<endl;
return 0;
}

output

0

1

2

3

Explain what an enumerated type is?SolutionEnum is also called enumerated Data type Enum is a user defined data type Syntax: of enumerated data type Enum is a d

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site