enumerations??

Write a program which makes use of enumerations. Define enumerations types and use them in code. To accomplish the task create an enumeration for colors containing values red, green, blue and yellow then:
a. Create enumeration instance with a default value
b. Display default value
c. Read an integer value from user and assign to enumeration instance variable
d. Display value of variable

i want code of this program

i will be very thank ful to you

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
using namespace std;

enum colors { red, green, blue, yellow };

int main() {

    colors c;

    c = red;
    cout<< "red = " << c << endl;

    c = green;
    cout << "green = " << c << endl;

    c = blue;
    cout << "blue = " << c <<endl;

    c = yellow;
    cout << "yellow = " << c << endl;

    return 0;
}
Last edited on
This is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again. As it is impossible to find derivative of function without knowledge in arithmetic, you cannot do more complex tasks in programming without clear understanding of basics
ok sir but kindly tell me what is enumerations?
we had not study about it and sir gave us assignment and what is default value i will write code if i know the meaning of enumerations and deafult value
i got the logic of program closed
Does your textbook really not explain what enumerations are?
Topic archived. No new replies allowed.