ProgrammingHard
printf("%d", 1 ? 'a' : 0); What is printed?
- A. a
- B. 1
- C. 97
- D. 0
Correct answer: C. 97
In the conditional operator the 'a' is an int constant of 97, so the printed value is 97, not the character.
More C Programming questions
- #define SQ(x) ((x) (x)) printf("%d", SQ(2 + 1)); What is printed?
- #define ADD(a, b) a + b printf("%d", ADD(1, 2) 3); What is printed?
- char grid[2] = {"ab", "cd"}; printf("%c", grid[1][0]); What is printed?
- struct S { int a; char c; } arr[2] = {{1}}; printf("%d", arr[1].a); What is printed?
- int a[5] = {[2] = 7, 9}; printf("%d", a[3]); What is printed?
- char s = "hi"; s++; printf("%s", s); What is printed?