ProgrammingHardHCL · Tech Mahindra pattern

Assume a 64-bit LP64 ABI. What is printed?

Assume a 64-bit LP64 ABI. What is printed?
int a = 100;
int *p = &a;
int *q = p;
p = NULL;
printf("%d %d", (p == NULL), (*q));
  1. A. 1 0
  2. B. 0 100
  3. C. 0 0
  4. D. 1 100

Correct answer: D. 1 100

q was assigned a COPY of p's original value (the address of a) before p was reassigned to NULL; reassigning p doesn't affect q at all, since pointer variables are independent once copied. p==NULL is true (1); *q still correctly dereferences a, giving 100.

More C Programming questions

Exams that ask this topic