ProgrammingVery hardIBM · Deloitte pattern
What is printed?
What is printed?
int a = 1, b = 2, c = 3;
int *arr[3] = {&a, &b, &c};
int **p = arr;
int ***pp = &p;
***pp += 100;
(*pp)++;
**pp += 100;
printf("%d %d %d", a, b, c);- A. 101 2 3
- B. 101 102 3
- C. 1 102 3
- D. 101 202 3
Correct answer: B. 101 102 3
***pp is a (through p[0]=&a), so a becomes 101. (*pp)++ advances p itself to point at arr[1] (&b). Now **pp is b, so b becomes 102. c is never touched. Output: 101 102 3.
More C Programming questions
- What is printed? c int a[6] = {1,2,3,4,5,6}; int p = a + 1; int q = a + 4; int diff = q - p; q -= diff / 3 2; printf("%d %d", diff, q);
- Assume a 64-bit LP64 ABI. What is printed? c int a[3][2] = {{1,2},{3,4},{5,6}}; int (p)[2] = a + 1; int q = (int)p; q++; printf("%d %d"…
- What is printed? c int a[3] = {5,10,15}; int p = a; int q = &a[2]; while (p != q) { printf("%d ", p); p++; } printf("%d", p);
- What is printed? c int a[3] = {1,2,3}; int p = a; int arrp[1] = {p}; int pp = arrp; (pp)[1] = 99; printf("%d %d %d", a[0], a[1], a[2]);
- What is printed? c int a[3] = {1,2,3}; int p = &a[1]; int x = p[1] - p[-1]; int y = (p+1) - (p-1); printf("%d %d", x, y);
- What is printed? c int add(int a,int b){ return a+b; } int sub(int a,int b){ return a-b; } int mul(int a,int b){ return ab; } int…