Difference Between Call By Value and Call By Reference?

Answer Posted / shrikant patil

Call by value method:
passing the value of variable to the function.
void main()
{
int x=10,y=20;
printf("%d%d',x,y);
swap(x,y);
}
void swap(int a,int b)
{
int c;
c=a;//changes here do not affect in values
a=b;//of x and y in main function..
b=c;
}

call by reference method:
passing the address of variable to the function.
swap(&a,&b)
&c=&a;
&a=&b;
&b=&c;
changes made in subfunction causes changes in address of
variables n thus in main () also..

Is This Answer Correct ?    155 Yes 33 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

when does a list get sent to the screen on the presentation layer?

1601


What are the different types of laws. What are they?

765


What is the use of the raising exception?

742


What is protect & endprotect?

746


What is the function module to popup contents in the internal table?

758






MY DOMAIN IS SAP-ABAP COMPARE TO WEBDYNPRO AND CRM-TECHNICAL WHICH IS BEST?

2658


Does the call transaction method allow multiple transactions to be processed by sap?

736


How the transaction that are programmed by the user can be protected?

822


What is the difference between a structure and an append structure?

741


What are system variable in abap?

790


How we format the data before writing a statement in the report?

693


Explain what is a foreign key relationship? Explain this with the help of an example.

796


What is the difference of update types in call transaction method ? : abap bdc

827


How do you connect to the remote server if you are working from the office for the client in remote place?

785


how to modify the standard method as per your requirement

1084