ProgrammingHardHCL · Tech Mahindra pattern

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

Assume a 64-bit LP64 ABI. What is printed?
int a[3] = {10, 20, 30};
int b[3] = {10, 20, 30};
printf("%d %d", a == b, *a == *b);
  1. A. 1 1
  2. B. 0 1
  3. C. 1 0
  4. D. 0 0

Correct answer: B. 0 1

a and b are two separate arrays with identical contents but different memory locations; when used in this context, both decay to pointers to their own first elements, which are different addresses, so a == b (comparing addresses) is 0. *a and *b dereference to compare the actual VALUES stored (both 10), which are equal, giving 1.

More C Programming questions

Exams that ask this topic