What will be the output of the following C program?

#include <stdio.h>

int main()
{
int x = 10;
int *p = &x;

```
printf("%d %d", sizeof(x), sizeof(p));

return 0;
```

}
                        

Options

  • A. 4 4
  • B. 4 8
  • C. 8 4
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. 4 8

Detailed Explanation

Correct Answer: 4 8 assuming a typical 64-bit system.

sizeof(x) gives the size of an integer. Under the assumption used in the question, this is 4 bytes.

sizeof(p) gives the size of the pointer variable itself, not the size of the integer to which it points.

On a typical 64-bit system, a pointer occupies 8 bytes. Therefore, the output is 4 8.

Important: Pointer size is implementation-dependent. BPSC questions normally provide the required assumption when the exact size matters.