Enumerations MCQs – Part 1

Timer: Off
Random: Off

1. What is an enumeration in C?
ⓐ. A way to define constants
ⓑ. A user-defined data type
ⓒ. A function
ⓓ. A type of loop
2. How do you define an enumeration in C?
ⓐ. enum {a, b, c};
ⓑ. typedef enum {a, b, c};
ⓒ. enum name {a, b, c};
ⓓ. typedef struct {a, b, c};
3. What is the default value of the first enumerator if not explicitly defined?
ⓐ. 0
ⓑ. 1
ⓒ. -1
ⓓ. 10
4. Which of the following correctly assigns a value to an enumerator?
ⓐ. enum {a, b, c = 10};
ⓑ. enum name {a = 5, b, c};
ⓒ. enum name {a, b = 3, c};
ⓓ. All of the above
5. How can you use an enumeration in a switch statement?
ⓐ. By converting it to an integer
ⓑ. Directly using the enumerator names
ⓒ. Using an enumeration pointer
ⓓ. By using the `enum` keyword inside the switch statement
6. Which of the following is a valid enumeration?
ⓐ. enum {RED, GREEN = 5, BLUE};
ⓑ. enum colors {RED, GREEN, BLUE};
ⓒ. enum colors {RED, GREEN, BLUE} myColor;
ⓓ. All of the above
7. What will be the value of BLUE in the following enumeration? enum colors {RED, GREEN = 3, BLUE};
ⓐ. 0
ⓑ. 1
ⓒ. 3
ⓓ. 4
8. How can you refer to an enumerator from an enumeration called `colors`?
ⓐ. colors::RED
ⓑ. RED
ⓒ. colors.RED
ⓓ. enum.colors.RED
9. What happens if you try to assign a floating-point value to an enumerator?
ⓐ. The value will be truncated
ⓑ. The value will be rounded
ⓒ. A compile-time error will occur
ⓓ. It will be converted to an integer
10. Which of the following is true about enumerations in C?
ⓐ. They can store multiple types of data
ⓑ. They can only store string values
ⓒ. They can be used as arrays
ⓓ. They help in making the code more readable and maintainable
Subscribe
Notify of
guest
1000


0 Comments
Inline Feedbacks
View all comments
0
Join Discussionsx
()
x