Practice mode C Language

What is printed by this C code: enum color { RED, GREEN = 5, BLUE }; printf(“%d %d”, RED, BLUE);?

Correct answer A. 0 6

Explanation

Enumeration constants start at 0 unless given a value, so RED is 0. GREEN is explicitly 5, and each constant without an initialiser is one more than the previous one, so BLUE is 6. Answer 0 2 ignores the explicit value given to GREEN. Enumeration constants in C have type int, so they print with %d.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.