ProgrammingVery hardGATE CS · Product company OA
On an LP64 system (8-byte pointers, 4-byte int), what is printed?
On an LP64 system (8-byte pointers, 4-byte int), what is printed?
int a[10];
printf("%zu %zu %zu", sizeof(&a), sizeof(*&a), sizeof(a + 0));- A. 8 40 8
- B. 40 40 40
- C. 40 40 8
- D. 8 8 8
Correct answer: A. 8 40 8
&a is a pointer (to the whole array), so 8. *&a is the array itself again, so sizeof sees 10 ints: 40. In a + 0 the array decays to int * before the addition, so the operand is a pointer: 8.
More C Programming questions
- What is printed? c int i = 0, j = 0; if (i++ & j++) ; if (i++ && j++) ; printf("%d %d", i, j);
- What is printed? c int a[6] = {4, 8, 15, 16, 23, 0}; int find(int x) { a[5] = x; int i = 0; while (a[i] != x) i++; return i < 5 ? i : -1…
- For ints a, b >= 0, which test correctly tells, before adding, whether a + b would overflow?
- What is printed? c const char s = " hi there you "; int words = 0, in = 0; for (; s; s++) { if (s == ' ') in = 0; else if (!in) { in = 1…
- What is printed? c int sub(const char a, const char b) { / is a a subsequence of b? / if (!a) return 1; if (!b) return 0; return sub(a ==…
- What is printed? c char src[] = "abc", dst[8]; char d = dst; const char s = src; while ((d++ = s++)); printf("%s %td %td", dst, d - dst, s…