Enumeration ( Keyword of enum ) is a user defined data type in C++.It consisting of named values like elements, members, etc., that represent integral constants. It provides a way to define and group integral constants. It also makes the code easy to maintain and less complex. They using for the Switch case. The switch statement is c++ multi-way branch statement. It is used to take the place of long if-else chains, and make them more readable. However, unlike if statements, one may not use inequalities; each value must be concretely defined.
The program demonstrates the usage of an enumerated data type in C++. An enumerated type is a user-defined data type that consists of a set of named constants.
#include<iostream> using namespace std; // ENUM in C++ enum gender {Male,Female}; int main() { gender g=Male; switch(g) { case Male: cout<<"Gender Male"; break; case Female: cout<<"Gender Female"; break; default: cout<<" Invalid"; break; } return 0; }
Gender MaleTo download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions