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 a help view? : abap data dictionary

662


What is the difference between commit-work and rollback-work tasks?

653


What are the main events of which are used for logical database?

593


What are aggregated objects : abap data dictionary

599


What is smart forms? : abap hr

598






A field containing currency amounts (data type curr) must be assigned to a reference table and a reference field. Explain?

861


What are the advantages of different types of bdc's?

526


What is the significance of technical settings (specified while creating a table in the data dictionary)? : abap data dictionary

603


how to create module pool program using table controls based on selection criteria specified for sales document item in the first screen and item details in the second screen. plz mention the detail coding Tahnks, Rahul

3408


How do you restrict the data to be entered in the payroll area? : sap abap hr

526


What is time constraint ? : abap hr

686


What are the different types of operators in the sap abap?

543


What is meant by slab? How is indian slab and us slab? : sap abap hr

554


What is payroll driver ? : abap hr

608


How collect statement is different from append?

528