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 the basic difference internal tables and database tables? : abap data dictionary

567


What is a function group? : abap modularization

590


What is the disadvantage of a call by reference?

640


What is the differrences between structure and table in data dictionary in abap? : abap hr

716


What is the difference between a pool table and a transparent table and how they are stored at the database level?

585






What are the function module in bdc?

641


Can i have some Realtime Scenarios on Reports.

1812


What are the function modules used in f4 help?

642


What are the disadvantages of abap query tool?

589


When value table becomes check table?

578


What function does data dictionary perform?

566


What are the time related infotypes? : abap hr

615


What are the two ways for restricting the value range for a domain? : abap data dictionary

532


What kind of deliverables you have on a day to day basis?

967


What are pooled tables? : abap data dictionary

663