Question discussion

What is the output of the following C program?#include enum color { RED = 5, GREEN, BLUE = 2, WHITE }; int main() { printf("%d %d %d", GREE…

2161Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C program?

#include <stdio.h>
enum color { RED = 5, GREEN, BLUE = 2, WHITE };
int main() {
    printf("%d %d %d", GREEN, BLUE, WHITE);
    return 0;
}
  • A6 2 2
  • B5 2 3
  • C6 2 3
  • D6 3 4
Correct answer: C

Explanation

An enumerator without an explicit value is one more than the previous one: GREEN = 6, BLUE = 2 and WHITE = 3.

Discussion 0

Nobody has replied yet. Start the discussion!