ProgrammingHardTCS NQT · Wipro

What is printed?

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

Correct answer: A. 1

sizeof a / sizeof a[0] is 3, so e points at a[2], which holds 1.

More C Programming questions

Exams that ask this topic