ProgrammingHardProduct company OA
Assume a 64-bit LP64 ABI. What is printed?
Assume a 64-bit LP64 ABI. What is printed?
struct K { const int a; int b; };
printf("%zu", sizeof(struct K));- A. 4
- B. 8
- C. 12
- D. 16
Correct answer: B. 8
The const qualifier affects how the compiler lets you use a, not its storage: a const int still occupies 4 bytes with 4-byte alignment, exactly like a plain int. a@0, b@4, total 8 bytes with no padding needed.
More C Programming questions
- 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))…
- What is printed? c #include <stdio.h> void inc(int a[], int n) { if (n == 0) return; a[n - 1]++; inc(a, n - 1); } int main(void) { int…