Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. 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
    1. S1 only
    2. S2 and S3
    3. S2 and S4
    4. S2 and S5
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.



Your comments will be displayed only after manual approval.