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

THANKS ALL. i CLEARED THE INTERVIEW OF INFOSYS BASED ON THIS QUESTION SET. IT REALLY WORKS. LONG LIVE ALLINTERVIEW.COM

15754


How do you find out who has transported a transport request?

611


B -Credit Note report Selection Screen Ranges: Creation date Sales Org Sold to Party Selection condition: Document Category – VBTYP should be ‘O’ Table to be used: VBRK, VBRP,VBPA,ADRC List the CR order types or credit billing type by customer number (or selected customer) and displays the: - Billing Document date (FKDAT) - Customer number (KUNRG) - Name of the reseller (on top of the SAP No) (NAME1) - Billing document number,(VBELN) - order reason (AUGRU_AUFT) - Amount (NETWR) - Currency (WAERK) Group Currency wise, billing type wise sum of Net value. When user double click on field ‘Billing Document #’ , display the document in VF03 Do this using OO ABAP.

2457


What are Delivery classes? What data will you want to transport during client copy?

979


What is view? Different types of view. Explain?

583






What are the contents in technical specifications?

600


Explain the difference between a pool table and a transparent table?

531


What are plan versions used for? : sap abap hr

570


What is an interface? In what scenario we use interface? What is the difference between abstract class and interface?

918


What is the diff between database view and maintenance view?

589


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

600


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

564


What is internal payroll process? : sap abap hr

586


what is difference between set screen and call screen ?

554


Explain how do you use structures in the abap programs?

538