-
Consider this code to swap integers and these five statements:
The code
S1 : will generate a compilation error
S2 : may generate a segmentation fault by runtime depending on the arguments passed
S3 : correctly implements the swap procedure for all input pointers referring to integers stored in memory locations accessible to the process
S4 : implements the swap procedure correctly for some but not all valid input pointers
S5 : may add or subtract integers and pointers
-
- S1 only
- S2 and S3
- S2 and S4
- S2 and S5
- S1 only
Correct Option: C
S2 : May generate segmentation fault if value at pointer Px or Py is constant or Px or Py point to a memory location that is invalid. And S4 : May not work for all inputs as arithmetic overflow can occur.