edited by
942 views
1 votes
1 votes
Program P1()
{
    x=10, y=3;
    func1(y,x,x);
    print x;
    print y; 
}
func1(x,y,z)
{
    y=y+4;
    z=x+y+4;
}


plzz elaborate the answer explanation?
thanks in advance.

edited by

1 Answer

Best answer
5 votes
5 votes

Program P1()
{
x=10, y=3;  at last x = 21 , y = 3
func1(&y,&x,&x);  //function call ( address of y ,address of x, address of x)
print x;        // x print = 21
print y;         // 3

}
func1(*x,*y,*z) // call comes here x= addresss of y , y= addresss of x , z= addresss of x  
*y= *y + 4;       // y contain = value at y address + 4 = 10 + 4 =14 
*z= *x + *y+4;      // z contain = value at address of y + value at address of y + 4 = 3 + 14 + 4=21
}

selected by

Related questions

0 votes
0 votes
1 answer
1
shree asked Nov 22, 2014
526 views
What will be the second value printed by the program if parameter passing mechanism is call by reference?int b=10 //global begin procedure func(int x,int y) begin print(b...
0 votes
0 votes
1 answer
2
Arun Rout asked Jan 7, 2019
742 views
#include<stdio.h>int fun(int arr[]){ arr=arr+1; printf("%d",arr[0]);}int main(void){ int arr ={10,20}; fun(arr); printf("%d",arr[0]); return 0;}A.COMPIL...
0 votes
0 votes
1 answer
3
Balaji Jegan asked Nov 15, 2018
1,346 views
Predict the Output for both the snippets for the following:1. Call by Value2. Call by Reference3. Call by Need4. Call by Name5. Call by value Result/Call by value Return(...
0 votes
0 votes
0 answers
4
Rahul_Rathod_ asked Oct 3, 2018
532 views
from below list of parameter passing techniques, which parameter passing technique we can implement in c?1) call by value2) call by refference3) call by value result4) ca...