Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
CPP All : Enumerated Types
Concept Notes and Resources
Concept Learning Code Sheets

Simple use of enumerated data type #4554

Understanding use of enumerated data type with a simple example.

#include <iostream>
using namespace std;
enum gender{MALE,FEMALE,OTHER};
int main()
{
gender g;
g = MALE;
cout<<g<<endl;
gender g1=FEMALE;
cout<<g1<<endl;
return 0;
}

Enumerated data type with given set of values #4565

Understanding use of enumerated data type with user given set of values and not by compiler default values.

#include <iostream>
using namespace std;
enum foam{soft=20,medium=40,hard=60};
int main()
{
foam x;
x=soft;
switch(x)
{
case soft: cout<<"Foam Hardness = "<<soft;break;
case medium: cout<<"Foam Hardness = "<<medium;break;
case hard: cout<<"Foam Hardness = "<<hard;break;
default:cout<<"Not in List";
}
return 0;
}

Finding size of enumerated data type #4567

Understanding how enum datatype is stored in memory

#include <iostream>
using namespace std;
enum divisions{first=1,second=2,third=3};
int main()
{
divisions d=first;
cout<<sizeof(d)<<endl;
return 0;
}


Quizzes

Concept Notes:1  Code Sheets:3  Quizzes:1
Back