ProgrammingModerateIBM · Deloitte pattern
What is printed?
What is printed?
enum { A, B = 5, C, D = 2, E };
printf("%d %d %d", A, C, E);- A. 1 6 3
- B. 0 2 4
- C. 0 6 3
- D. 0 6 6
Correct answer: C. 0 6 3
Enumerators start at 0 and each one without a value is the previous plus 1: A = 0, B = 5, C = 6, D = 2, E = 3. Values may repeat or go down.
More C Programming questions
- With 4-byte int, what is printed? c int a[] = {1, 2, 3}; char p = (char )a; p += 4; printf("%d", (int )p);
- What is printed? c int a[2][3] = {{1, 2, 3}, {4, 5, 6}}; printf("%d %d", ((a + 1) + 2), a + 1);
- What is printed? c int x = 3; if (x = 0) printf("A%d", x); else printf("B%d", x);
- What is printed? c int add(int a, int b) { return a + b; } ... int (fp)(int, int) = add; printf("%d", (fp)(2, 3) + fp(4, 5));
- What is printed? c #define MAX(a, b) ((a) > (b) ? (a) : (b)) int x = 3, y = 5; int z = MAX(x++, y++); printf("%d %d %d", x, y, z);
- What is printed? c int i = 0, j = 1, k; k = i++ && j++ || ++j; printf("%d %d %d", i, j, k);