Write a C++ program to illustrate Enumerations.
AIM:
Write
a C++ program to illustrate Enumerations.
THEORY:
An enumeration is a distinct type
whose value is restricted to a range of values (see below for details), which
may include several explicitly named constants ("enumerators"). The values of the constants are values of an
integral type known as the underlying
type of the enumeration.
SOURCE
CODE:
#include<iostream>
using namespace std;
enum
week{Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturda};
enum Season{spring=34,Summer=4,Autumn=9,Winter=32};
int main()
{
week
today;
today=Wednesday;
cout<<"Day"<<today+1<<"\n";
Season
S;
S=Summer;
cout<<"summer=
"<<S<<endl;
return
0;
}
Labels: oop through c++ lab
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home