Output of the c program2


The value printed by the following program is ____________
void f(int *p,int m)
void main()
int i=5,j=10;


The output will be 30. This is a question of call by reference and call by value concept of pointers. If you look at the function “f”, you will see a pointer *p and a variable m of integer types. In main function you send the address of i to the pointer *p of function. So, here the data operations will occur at the address of i. On the other hand, the data of j is copied to variable m in the function and the operations are done on the copy of variable “j” of main function. So,
m=m+5 will change value of m to 15
*p=*p+m will change the value at address of “i” to 5+15=20
At next step of the main function, values of i and j are now, i=20 and j=10
So, printing i+j will give 30