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);- A. 0 1
- B. 1 0
- C. 0 0
- 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
- Assume a 64-bit LP64 ABI. What is printed? c int a[2][3] = {{1, 2, 3}, {4, 5, 6}}; int p = (int )a; for (int i = 0; i < 6; i++)…
- Assume a 64-bit LP64 ABI (natural alignment, no #pragma pack). What is printed? c struct A { char c; int i; char d; }; struct B { int i…
- Assume a 64-bit LP64 ABI. What is printed? c union U { int i; char c[4]; double d; }; printf("%zu", sizeof(union U));
- Assume a little-endian 64-bit machine. What is printed? c union U { int i; char bytes[4]; }; union U u; u.i = 0x01020304; printf("%x %x %x…
- Assume a 64-bit LP64 ABI. What is printed? c struct Point { int x; int y; }; struct Rect { struct Point tl; struct Point br; }…
- Assume a 64-bit LP64 ABI. What is printed? c union Data { int i; float f; }; union Data d; d.i = 1065353216; printf("%.1f", d.f);