ProgrammingHardIBM · Deloitte pattern

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

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

Correct answer: D. 1 1

p1 and p2 both hold the address of the same variable a, so comparing the pointers themselves (p1 == p2) compares those two identical address values, giving true (1). Dereferencing both and comparing the pointed-to values (*p1 == *p2) also gives true, since both read the same a (5 == 5).

More C Programming questions

Exams that ask this topic