IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Difference between call by value and call by reference


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
varun kumar

New User


Joined: 20 Oct 2005
Posts: 1

PostPosted: Thu Oct 20, 2005 1:20 pm
Reply with quote

what is the difference between call by value and call by reference.
Back to top
View user's profile Send private message
sairam

New User


Joined: 30 Aug 2005
Posts: 58
Location: Kolkata

PostPosted: Thu Oct 20, 2005 1:40 pm
Reply with quote

Hi Varun

Call by value means the values will be passed in the calling function.The called function uses this values.The original variable doesnot change.It's value remain unchanged.

Ex
main function {
.
int a,b;
.
Call fun(a,b)
.
.


}

fun(int c,int d)
{

c=c+1;d=d+1;

}

here the changes of value will not be reflected in the variable passed as
parameter in calling function in main.

In case of call by reference the address of variable is passed,so change in the called function will be reflected in called function.

Hi if any doubt please let me know,i explained it shortly
Back to top
View user's profile Send private message
karthi_ind

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Fri Oct 21, 2005 11:33 am
Reply with quote

Hi Varun


This question has been answered so mny times.
Plz do search in the forum before ask questions.

Answer for ur question is

Parameters can be passed either by reference or conten(value).
If a paremeter is passed by reference both the called and calling program share the same storage space, so if any changes in the formal parameters (Called pgm parameters) will reflect in the actual paramers (calling pgm).

If a parameter is passed by content , calling and called do not share the same storage, so any changes in the called pgm will not reflect in the calling pgm . This is the difference.

Call by reference is default.

If you knw C language , thr is a concept called pointer which uses addressing. (means call by reference)

Corrections are welcome.


Karthi G.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Call program, directly from panel CLIST & REXX 9
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts Batch call online program, EXCI task ... CICS 3
Search our Forums:

Back to Top