ProgrammingHard
int a[] = {4, 5, 6}; int *p = &a[2]; printf("%d", *(p - 2)); What is printed?
- A. 5
- B. 6
- C. 0
- D. 4
Correct answer: D. 4
p = &a[2], and p - 2 steps back two ints to a[0], so the output is 4. 6 ignores the subtraction, and 5 steps back only one element.
More C Programming questions
- int v = 10; int p = &v; int q = &p; q += 5; printf("%d", v); What is printed?
- printf("%d", sizeof(int[4]) / sizeof(int)); What is printed with 4-byte int?
- printf("%d", (int)(0.1 + 0.2 == 0.3)); What is printed in IEEE double arithmetic?
- printf("%d", 'a' < 'b' && 'b' < 'c'); What is printed?
- printf("%d %d", 5 / 2, -5 / 2); What is printed in C99?
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint32t v = 0x00F0F0A5u; v = v - ((v >> 1) & 0x55555555u); v =…