Question discussion

On a 64-bit system with 4-byte integers, what is the output of the following C program?#include void f(int a[10]) { printf("%d ", (int)size…

1968Medium DSSSB TGT Computer Science 0 replies

On a 64-bit system with 4-byte integers, what is the output of the following C program?

#include <stdio.h>
void f(int a[10]) { printf("%d ", (int)sizeof(a)); }
int main() {
    int b[10];
    f(b);
    printf("%d", (int)sizeof(b));
    return 0;
}
  • A40 40
  • B8 40
  • C4 40
  • D10 10
Correct answer: B

Explanation

An array parameter is really a pointer (8 bytes), whereas sizeof applied to the actual array b gives 10 × 4 = 40 bytes.

Discussion 0

Nobody has replied yet. Start the discussion!