ProgrammingVery hardGATE CS · Campus placements
int a[3] = {1, 2, 3}; int *p = a; int (*q)[3] = &a; printf("%d", *(*q + 2) + *(p + 1)); What is printed?
- A. 3
- B. 4
- C. 6
- D. 5
Correct answer: D. 5
*q decays to a pointer to a[0], so *(*q + 2) is a[2] = 3. *(p + 1) is a[1] = 2, and 3 + 2 = 5.
More C Programming questions
- unsigned char x = 0; x--; What is x?
- Which statement about the return value of strcmp is true?
- For 4-bit masks (bits 0 to 3), how many masks have both bit 0 and bit 2 set?
- What is the value of (1ULL << 63) >> 62 for uint64t arithmetic?
- uint8t a = 200, b = 250; uint8t avg = (a + b) / 2; What is avg?
- What is the value of 1 + 2 3 << 1 in C?