Sunday, August 2, 2009

Write a program in C using call by reference?

program to calculate the age of a person through month, date and year entered by the user?

Write a program in C using call by reference?
The call by reference is one of the time and memory saving ways to call a function.





Go this way...





suppose a main function is their:-





main()


{


int a,b;


int c;


a=30;


b=40;


c=add(a,b);


printf("\nValue of c=",c);


}








and the function for add is:-





int add(int %26amp;x,int %26amp;y)


{


int z;


z=x+y;


return z;


}





now what happens here is the "%26amp;" specifies that the variables used are actually diff name for the original variables. Hence if you change the variables in function then the original variables will also be changed....





ask more to me on...arjun_devane@yahoo.com
Reply:what are you asking ?





by the sound of it anything will do provided the call uses a reference rather than the value as in





myproc (byref myvar)


No comments:

Post a Comment