closed by
997 views
0 votes
0 votes
closed as a duplicate of: GATE CSE 2006 | Question: 57
Consider this C code to swap two integers and these five statements :
void swap (int * px, int * py)
{
           * px = *px – *py ;
           *py = *px + *py;
           *px = *py – *px;
}
S1 :  Will generate a compilation error
S2 :  May generate a segmentation fault at runtime depending on the arguments passed
S3 :  Correctly implement 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.
(A) S1            (B) S2 and S3         (C) S2 and S4        (D) S2 and S5
closed by

Related questions

1 votes
1 votes
0 answers
1
0 votes
0 votes
1 answer
3
radha gogia asked Jul 28, 2015
974 views
int * p(void) { int *x; *x=10; return (x); } We create *x, and dereference it before assigning anything to it (x). Most likely, when we are declaring something on the sta...
0 votes
0 votes
1 answer
4