C - Enum MCQ Questions

This section focuses on the "Enum" in C programming language. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. Enumeration (or enum) is a ______ data type in C?

A. user defined
B. built-in
C. libary
D. None Of the above

View Answer

2. If we do not explicitly assign values to enum names, the compiler by default assigns values to ?

A. null
B. -1
C. 0
D. Garbage

View Answer


3. All enum constants are?

A. Same in their scope
B. unique in their scope
C. contain dupicate value in their scope
D. None of the above

View Answer


4. String handling functions such as strcmp(), strcpy() etc can be used with enumerated types.

A. True
B. False

View Answer


5. Pick the incorrect statement with respect to enums.

A. Two enum symbols cannot have the same value
B. Only integer constants are allowed in enums
C. It is not possible to change the value of enum symbols
D. Enum variables are automatically assigned values if no value is specified

View Answer


6. Arithmetic operations are not allowed on enumerated constants.

A. True
B. False

View Answer


7. What will be output for the following code?

main()
{
    enum test {success, failure};
    enum test t1,t2;
    t1=success;
    t2=failure;
    printf("%d",t1);
}

A. error
B. success
C. failure
D. 0

View Answer


8. What will be output for the following code?

 main()
{
    enum test {success, failure};
    enum test t1,t2;
    t1=success;
    t2=failure;
    printf("%d",t1);
}

A. error
B. success
C. failure
D. 0

View Answer


9. What will be output for the following code?

enum lfc
{
    x,y,z=10
};
enum lfc l;
main()
{
    a++;
    printf("%d",a);
}

A. Error
B. 5
C. 6
D. 2

View Answer


10. What is the correct syntax of enum?

A. enum flag{constant1, constant2, constant3, ....... };
B. enum flag(constant1, constant2, constant3, ....... );
C. enum flag[constant1, constant2, constant3, ....... ];
D. enumflag{constant1, constant2, constant3, ....... };

View Answer






Also check :


Discussion


* You must be logged in to add comment.