C Programming - Structures, Unions, Enums - Discussion

Discussion Forum : Structures, Unions, Enums - True / False Questions (Q.No. 6)
6.
Which of the following statement is True?
User has to explicitly define the numeric value of enumerations
User has a control over the size of enumeration variables.
Enumeration can have an effect local to the block, if desired
Enumerations have a global effect throughout the file.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
12 comments Page 1 of 2.

Swapnil said:   9 years ago
D option is also correct, if we define enum globally.
(4)

Kavitha said:   2 decades ago
eg:

void add()
{
enum a={mon,tue,wed};
..
..
}


here the enum variables are available only to the add method and not to anyother methods.
(3)

Swapnil said:   2 decades ago
please give me example

Arjun said:   1 decade ago
very nice kavitha

Madan said:   1 decade ago
User has a control over the size of enumeration variables.

I didn't understand the meaning of this statement.
Will anybody explain with simple example?

Rajat said:   1 decade ago
@Madan.

Size of enum is always 4.

Krr said:   1 decade ago
Size of enum is always 2. It is considered as int by default.

Mehdi said:   10 years ago
Hi, but in the recent developments of C++ (11 & 14) you can set an underlying type which able you to set the size of the variables of enumeration as you wish. Maybe it will be accessible in C someday.

Nehal said:   9 years ago
@Kavitha.

Nice explanation.

Nick said:   8 years ago
Incorrect - most embedded C compilers allow the size of an enumeration to be 1 or 2 bytes.


Post your comments here:

Your comments will be displayed after verification.