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

What is an update task? : abap modularization

586


What is the use of abap data dictionary? : abap data dictionary

568


Difference between stand alone CRM and back-end CRM

3811


Explain what is sap script?

634


What are the differences between macro and subroutine?

608






What is locking? : abap data dictionary

617


Final class

1008


dear friends, do you know how to configure web dynpro and adobe into ECC6.0 IDES?

2536


Explain what are the system fields? Explain?

551


How do you write a function module in sap?

608


what is call back in alv?

1965


How can cluster table be created?

650


Have you set up a back ground job ? How to create a background job without a variant ?

638


What are the different types of views and their definition?

582


Which objects are independent transport objects? : abap data dictionary

564