ProgrammingHardGATE CS · Infosys

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    int a[] = {1, 2, 3, 4, 5}, *p = a;
    printf("%d", *(p + *(p + 2)));
}
  1. A. 3
  2. B. 5
  3. C. 2
  4. D. 4

Correct answer: D. 4

*(p + 2) is 3, so the expression reads *(p + 3), which is 4.

More C Programming questions

Exams that ask this topic