ProgrammingHardTCS NQT · Infosys pattern
Assume a 64-bit LP64 ABI. What is printed?
Assume a 64-bit LP64 ABI. What is printed?
int a = 10;
int *p = &a;
int **pp = &p;
**pp = 20;
printf("%d %d %d", a, *p, **pp);- A. 10 10 10
- B. 20 20 20
- C. 10 20 20
- D. 20 10 20
Correct answer: B. 20 20 20
pp holds the address of p, so **pp dereferences pp to get p, then dereferences p to get a. Assigning 20 through **pp writes directly into a, so all three expressions (a, *p, **pp) now read the same updated value: 20 20 20.
More C Programming questions
- Assume a 64-bit LP64 ABI. What is printed? c char names[] = {"Alice", "Bob", "Carol"}; char p = names; p++; printf("%s %s", p, (names + 2));
- Assume a 64-bit LP64 ABI. What is printed? c int a[5] = {10, 20, 30, 40, 50}; int p = a + 4; int q = a; printf("%ld %d %d", p - q, (p…
- Assume a 64-bit LP64 ABI. What is printed? c void modify(int arr[], int n) { for (int i = 0; i < n; i++) arr[i] += 100; } int main(void) {…
- Assume a 64-bit LP64 ABI. What is printed? c int nums[] = {1, 2, 3, 4, 5}; int p = nums; for (int i = 0; i < 5; i++) { printf("%d ", p); p…
- Assume a 64-bit LP64 ABI. What is printed? c int a = 5; int p = &a; void vp = p; int p2 = (int )vp; p2 = 99; printf("%d %d", a, p);
- Assume a 64-bit LP64 ABI. What is printed? c int a[3] = {1, 2, 3}; int p = a; int q = &a[2]; ptrdifft diff = q - p; printf("%td %d", diff…