ProgrammingModerateProduct-company MCQ pattern
On a 64-bit system (8-byte pointers, 4-byte int), what does f print?
On a 64-bit system (8-byte pointers, 4-byte int), what does f print?
void f(int a[10]) {
printf("%zu", sizeof(a));
}- A. 10
- B. 40
- C. 8
- D. 4
Correct answer: C. 8
An array parameter is adjusted to a pointer: int a[10] in a parameter list means int *a. So sizeof(a) is the size of a pointer, 8, not 10 × 4 = 40. This is why array length must be passed separately.
More C Programming questions
- How many times is fib called in total (including the first call) when evaluating fib(5)? c int fib(int n) { if (n <= 1) return n; return…
- What is printed? c int x = 181, c = 0; while (x) { x &= x - 1; c++; } printf("%d", c);
- What is printed? c printf("%d", 1 << 3 + 1);
- On a typical compiler where int is 4 bytes and 4-byte aligned, what is printed? c struct S { char c; int i; char d; }; struct T { int i…
- With 4-byte int, consider int (p)[5]; Which is correct?
- int a[3][4]; is stored in row-major order starting at address 1000, with 4-byte int. What is the address of a[2][1]?