ProgrammingHardProduct company OA
Assume a 64-bit LP64 ABI. What is printed?
Assume a 64-bit LP64 ABI. What is printed?
union Val { int i; float f; };
union Val arr[4];
printf("%zu %zu", sizeof(union Val), sizeof(arr));- A. 8 32
- B. 4 8
- C. 8 16
- D. 4 16
Correct answer: D. 4 16
Both members of Val are 4 bytes with 4-byte alignment, so the union itself is 4 bytes. An array of 4 such unions is simply 4 x 4 = 16 bytes.
More C Programming questions
- Assume a 64-bit LP64 ABI. What is printed? c struct K { const int a; int b; }; printf("%zu", sizeof(struct K));
- What is printed? c #include <stdio.h> int f(int n) { static int sum = 0; sum += n; if (n == 0) return sum; return f(n - 1); } int…
- What is printed? c #include <stdio.h> void f(int n) { if (n == 0) return; printf("%d ", n); f(n - 1); printf("%d ", n); } int main(void) {…
- What is printed? c #include <stdio.h> void rev(const char s) { if (s == '0') return; rev(s + 1); putchar(s); } int main(void) {…
- What is printed? c #include <stdio.h> int isEven(int n); int isOdd(int n) { if (n == 0) return 0; return isEven(n - 1); } int isEven(int…
- What is printed? c #include <stdio.h> int trace(int n) { printf("t%d ", n); return n == 0; } int f(int n) { if (trace(n) || f(n - 1))…