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

Programming and data structure miscellaneous

Programming & Data Structure

  1. The value printed by the following program is _______.
    void f(int* p, int m){
    m = m + 5;
    *p = *p+m;
    return;
    }
    void main () {
    int i=5, j=10;
    f(& i, j);
    printf (“%d”, i+j);
    }
    1. 0
    2. 10
    3. 15
    4. 30
Correct Option: D

The address of i and value of j are passed to the function of f. f modifies i’s value to 20. j’s value remains same (as its value is passed not the reference). The value printed by the program will be i + j = 20 + 10 = 30.



Your comments will be displayed only after manual approval.