MCQ Hive stays free thanks to ads. Please disable your ad blocker for this site so content and features keep working.
Data Types
Structures, Unions & Enums
Beginner
Q
In C/C++, given enum Color { RED, GREEN = 5, BLUE };, what is the value of BLUE?
B2
C5
D6
Correct Answer:
D. 6
Explanation:
Enumerators start at 0 and each one is the previous value plus 1. GREEN is set to 5, so BLUE is 6.
ALSO KNOW (related points):
• What is the main advantage of a C++11 enum class over a plain enum? → Its enumerators are scoped and do not implicitly convert to int