ProgrammingHardIBM · Deloitte pattern

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

Assume a 64-bit LP64 ABI. What is printed?
int f(int *p) {
    *p = 50;
    return *p + 10;
}
int main(void) {
    int a = 5;
    int result = f(&a);
    printf("%d %d", a, result);
}
  1. A. 50 60
  2. B. 5 60
  3. C. 5 15
  4. D. 50 15

Correct answer: A. 50 60

f receives the address of a, so *p = 50 directly mutates a itself through the pointer, making a = 50 after the call. The function then returns *p + 10 = 50 + 10 = 60.

More C Programming questions

Exams that ask this topic