Tuesday 3 February 2015

Enumeration in C++

Structure of the Problem Requirements  

Enumeration is a user-defined type whose value is restricted to one of several explicitly named constants(enumerators). enum is the key word that is use for this. In this code first we declare global enum declaration, in which we have four values and then in main program we can make a instance of enum and then use it.

Source Code

#include <iostream>
using namespace std;
enum number { one = 1, two = 4, three = 9, four = 16};
int main() {
number n;
n = four;
cout<<"\n\n\t ****** Enumeration ******** \n\n";
cout << "Four Square : " << n << endl;
return 0;
}

Output of the Program

Enumeration in C++

Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment