Topic:
“EnumerationType”
 You have an array that stores your grades like:
int Grade[5];
 Now, you need to assign the grades of your subjects like:
(Math, English, Biology, Chemistry, History)
to your array.
 So, in Math you have a grade 1
Grade[0] = 1; // Math --> 1
for English you have a grade 3
Grade[1] = 3; // English --> 3
 Later in your code, you want to retrieve the grade of English. For that you will
have to remember that in your Grade[ ] array the second entry [1] would be
English.
WITH ENUMERATION WE CAN DO IT IN AN EASY WAY.
 First we are gonna know the meaning of the
the word enumeration, generally.
“It is the action of mentioning a number of things
one by one”
 In C++, enumeration means,
“An Enumeration is user-defined data type that
consists of Integral constants”
 ‘enum’ keyword is used to define and
enumeration.
enum season { spring, summer, autumn, winter };
 Here, the name of the enumeration is season.
 And, spring, summer and winter are values
of type season.
 By default, spring is 0, summer is 1 and so on.
You can change the default value of an enum
element during declaration
SYNTAX:
enum subject {
Math,
English,
Biology,
Chemistry,
History
};
 Now every subject in the brackets will get their index number,
without us to mention like,
Math = 0
English=1
Biology=2 //Which makes the Grade[5], in total.
Chemistry =3
History= 4
 The expression Grade[0] is the same as
Grade[math]
Grade[0] = 1; // Math --> 1
 You do not need to know which subject
has which index any more, you simply call
them by their name.
SOURCE CODE:
#include <iostream>
using namespace std;
enum week {
Monday,
Tuesday, FOR INSTANCE:
Wednesday, If I initialize only Monday as to (Monday=1)
Thursday , then?
Friday,
Saturday,
Sunday };
int main()
{
week today;
today = Monday;
cout << "Day: " << today +1;
return 0;
}
#include<iostream>
using namespace std;
enum suit{
spade, SPADE HEART
club,
heart,
diamond
};
int main()
{
suit mycard;
suit hercard;
mycard= club; DIAMOND CLUB
hercard= heart;
if(mycard>hercard)
{
cout<<"You win!"<<endl;
}else
{
cout<<"You lose!"<<endl;
}
return 0;
}
Cout<<“THANKYOU”;

More Related Content

PPTX
Blueprint.pdf
DOC
Sample verified statement to disqualify judge in California
PDF
ENUM - make u r names as data types
PPTX
Enumration datatype
PPTX
PPSX
6 enumerated, typedef
PPTX
Enum
PPTX
Enumerated data types
Blueprint.pdf
Sample verified statement to disqualify judge in California
ENUM - make u r names as data types
Enumration datatype
6 enumerated, typedef
Enum
Enumerated data types

Similar to Enumeration type (20)

PDF
2 BytesC++ course_2014_c2_ flow of control
PPT
Structure and Enum in c#
PPT
Lecture 8
PPTX
Tokens expressionsin C++
PDF
C++ tokens and expressions
PPTX
21CS642 Module 1 Enumerations PPT.pptx VI SEM CSE 2021 Batch Students
PPTX
8enum in c#
PDF
Programming methodology lecture12
PPTX
Intro To C++ - Class 04 - An Introduction To C++ Programming, Part III
PDF
15 1. enumeration
PPTX
C programming enumeration
PPTX
intro to programming presentation .pptx
PPTX
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
PPTX
Lecture 6 Enumeration in java ADVANCE.pptx
PPTX
Introduction to C++ lecture ************
PDF
Introduction to C++
PDF
BASIC C++ PROGRAMMING
PPT
Data Handling
PDF
Object Oriented Programming (OOP) using C++ - Lecture 2
PDF
C++ Course - Lesson 2
2 BytesC++ course_2014_c2_ flow of control
Structure and Enum in c#
Lecture 8
Tokens expressionsin C++
C++ tokens and expressions
21CS642 Module 1 Enumerations PPT.pptx VI SEM CSE 2021 Batch Students
8enum in c#
Programming methodology lecture12
Intro To C++ - Class 04 - An Introduction To C++ Programming, Part III
15 1. enumeration
C programming enumeration
intro to programming presentation .pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
Lecture 6 Enumeration in java ADVANCE.pptx
Introduction to C++ lecture ************
Introduction to C++
BASIC C++ PROGRAMMING
Data Handling
Object Oriented Programming (OOP) using C++ - Lecture 2
C++ Course - Lesson 2
Ad

Recently uploaded (20)

PDF
Navigating the Thai Supplements Landscape.pdf
PPT
statistic analysis for study - data collection
PPTX
New ISO 27001_2022 standard and the changes
PPTX
SET 1 Compulsory MNH machine learning intro
PPT
PROJECT CYCLE MANAGEMENT FRAMEWORK (PCM).ppt
PPTX
recommendation Project PPT with details attached
PPTX
IMPACT OF LANDSLIDE.....................
PDF
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
PPTX
sac 451hinhgsgshssjsjsjheegdggeegegdggddgeg.pptx
PPTX
retention in jsjsksksksnbsndjddjdnFPD.pptx
PPTX
chuitkarjhanbijunsdivndsijvndiucbhsaxnmzsicvjsd
PDF
An essential collection of rules designed to help businesses manage and reduc...
PDF
©️ 02_SKU Automatic SW Robotics for Microsoft PC.pdf
PDF
Session 11 - Data Visualization Storytelling (2).pdf
PPTX
CHAPTER-2-THE-ACCOUNTING-PROCESS-2-4.pptx
PPTX
ai agent creaction with langgraph_presentation_
PDF
Systems Analysis and Design, 12th Edition by Scott Tilley Test Bank.pdf
PPTX
Lesson-01intheselfoflifeofthekennyrogersoftheunderstandoftheunderstanded
PPTX
eGramSWARAJ-PPT Training Module for beginners
PPTX
statsppt this is statistics ppt for giving knowledge about this topic
Navigating the Thai Supplements Landscape.pdf
statistic analysis for study - data collection
New ISO 27001_2022 standard and the changes
SET 1 Compulsory MNH machine learning intro
PROJECT CYCLE MANAGEMENT FRAMEWORK (PCM).ppt
recommendation Project PPT with details attached
IMPACT OF LANDSLIDE.....................
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
sac 451hinhgsgshssjsjsjheegdggeegegdggddgeg.pptx
retention in jsjsksksksnbsndjddjdnFPD.pptx
chuitkarjhanbijunsdivndsijvndiucbhsaxnmzsicvjsd
An essential collection of rules designed to help businesses manage and reduc...
©️ 02_SKU Automatic SW Robotics for Microsoft PC.pdf
Session 11 - Data Visualization Storytelling (2).pdf
CHAPTER-2-THE-ACCOUNTING-PROCESS-2-4.pptx
ai agent creaction with langgraph_presentation_
Systems Analysis and Design, 12th Edition by Scott Tilley Test Bank.pdf
Lesson-01intheselfoflifeofthekennyrogersoftheunderstandoftheunderstanded
eGramSWARAJ-PPT Training Module for beginners
statsppt this is statistics ppt for giving knowledge about this topic
Ad

Enumeration type

  • 2.  You have an array that stores your grades like: int Grade[5];  Now, you need to assign the grades of your subjects like: (Math, English, Biology, Chemistry, History) to your array.  So, in Math you have a grade 1 Grade[0] = 1; // Math --> 1 for English you have a grade 3 Grade[1] = 3; // English --> 3  Later in your code, you want to retrieve the grade of English. For that you will have to remember that in your Grade[ ] array the second entry [1] would be English. WITH ENUMERATION WE CAN DO IT IN AN EASY WAY.
  • 3.  First we are gonna know the meaning of the the word enumeration, generally. “It is the action of mentioning a number of things one by one”  In C++, enumeration means, “An Enumeration is user-defined data type that consists of Integral constants”  ‘enum’ keyword is used to define and enumeration.
  • 4. enum season { spring, summer, autumn, winter };  Here, the name of the enumeration is season.  And, spring, summer and winter are values of type season.  By default, spring is 0, summer is 1 and so on. You can change the default value of an enum element during declaration
  • 5. SYNTAX: enum subject { Math, English, Biology, Chemistry, History };  Now every subject in the brackets will get their index number, without us to mention like, Math = 0 English=1 Biology=2 //Which makes the Grade[5], in total. Chemistry =3 History= 4
  • 6.  The expression Grade[0] is the same as Grade[math] Grade[0] = 1; // Math --> 1  You do not need to know which subject has which index any more, you simply call them by their name.
  • 7. SOURCE CODE: #include <iostream> using namespace std; enum week { Monday, Tuesday, FOR INSTANCE: Wednesday, If I initialize only Monday as to (Monday=1) Thursday , then? Friday, Saturday, Sunday }; int main() { week today; today = Monday; cout << "Day: " << today +1; return 0; }
  • 8. #include<iostream> using namespace std; enum suit{ spade, SPADE HEART club, heart, diamond }; int main() { suit mycard; suit hercard; mycard= club; DIAMOND CLUB hercard= heart; if(mycard>hercard) { cout<<"You win!"<<endl; }else { cout<<"You lose!"<<endl; } return 0; }