ProgrammingHardIBM · Deloitte pattern

Assume a 64-bit LP64 ABI. What is printed?

Assume a 64-bit LP64 ABI. What is printed?
int x = 10;
int *p = &x;
*p = *p * *p;
printf("%d", x);
  1. A. 100
  2. B. 20
  3. C. 10
  4. D. 0

Correct answer: A. 100

*p * *p reads x twice (10*10=100) before the single assignment writes the result back into x through p; there's no unsequenced hazard here since both reads happen before the one write. Final x = 100.

More C Programming questions

Exams that ask this topic