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

Programming and data structure miscellaneous

Programming & Data Structure

  1. Consider the following function implemented in C :
    void printxy (int x, int y) {
        int *ptr;
        x = 0;
        ptr = &x;
        y = *ptr;
        *ptr = 1;
        printf (“%d, %d”, x,y);
    }
    The output of invoking printxy (1,1) is
    1. 0, 0
    2. 0, 1
    3. 1, 0
    4. 1, 1
Correct Option: C

int * Ptr;
X = 0;

Ptr = & X
Y = *Ptr
⇒ (Y = 0)
*Ptr = 1;

⇒ (X = 1)
So, the output of invoking print XY(1, 1) is
⇒ (1, 0)
Hence, option (c) is correct.



Your comments will be displayed only after manual approval.