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

Programming and data structure miscellaneous

Programming & Data Structure

  1. What does the following program print?
    #include < stdio.h >
    void f (int *p, int *q)
       p = q;
    *p = 2;
    }
    int i = 0, j = 1;
    int main () {
       f(&i, &j);
       printf(“%d%d/n”, i, j);
    }
    1. 2 2
    2. 2 1
    3. 0 1
    4. 0 2
Correct Option: D

* p points to i and q points to j */
void f(int *p, int *q)
{
p = q; /* p also points to j now */
*p = 2; /* Value of j is changed to 2 now */
}



Your comments will be displayed only after manual approval.