Question discussion

What is the output of the following C code? int x = 10; void modify(int *p) { *p += 5; p = NULL; } int main() { int *ptr = &x; modify(ptr);…

545Medium DSSSB TGT Computer Science 0 replies 1 views
0
What is the output of the following C code? int x = 10; void modify(int *p) { *p += 5; p = NULL; } int main() { int *ptr = &x; modify(ptr); printf("%d", *ptr); return 0; }
  • A10
  • B15
  • CCompilation error
  • DSegmentation fault
Correct answer: B

Discussion 0

Nobody has replied yet. Start the discussion!