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));
}
  1. A. 10
  2. B. 40
  3. C. 8
  4. 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

Exams that ask this topic