Procedure Parameters

What is call by value and call by reference in parameters (IN, OUT, INOUT)?

Questions by arunnaa

Editorial / Best Answer

lisha.varghese  

  • Member Since Nov-2008 | Nov 17th, 2008


Three types of parameter modes

1) IN parameter mode- This mode is used to pass values to the calling module when invoked.The value of IN parameter can't be changed in the module.

2) OUT parameter mode -This mode is used to return a value to the main block.The value of OUT parameter can change anywhere in the program.

3)IN OUT parameter mode-This mode is used to pass values to the calling module and return a value to the main block.The value of IN OUT parameter can change anywhere in the program.

In Call By value ,the copy of actual parameter is passed to the formal parameter,So any changes to the formal parameter doesn't affect the actual parameter.

In Call By reference,the address of actual parameter is passed to the formal parameter,so any changes to the formal parameter will change the actual parameter also,because both of them are pointing to the same memory location.
Here  no copying is required.
 
The IN parameter is passe by reference,so we can't change the value of IN parameter inside the module,It acts as a constant,But the OUT and IN OUT parameters are passed by value,we can change the values of OUT &  IN OUT paremeters

Showing Answers 1 - 15 of 15 Answers

kz4ora

  • Nov 8th, 2008
 

There are 3 types parameters

IN - Default mode,using this value is passed to procedure

OUT- Value is returned to calling environment

IN OUT- Does both- Value passed to procedure and can be used to return some value to calling environment

 

  Was this answer useful?  Yes

Three types of parameter modes

1) IN parameter mode- This mode is used to pass values to the calling module when invoked.The value of IN parameter can't be changed in the module.

2) OUT parameter mode -This mode is used to return a value to the main block.The value of OUT parameter can change anywhere in the program.

3)IN OUT parameter mode-This mode is used to pass values to the calling module and return a value to the main block.The value of IN OUT parameter can change anywhere in the program.

In Call By value ,the copy of actual parameter is passed to the formal parameter,So any changes to the formal parameter doesn't affect the actual parameter.

In Call By reference,the address of actual parameter is passed to the formal parameter,so any changes to the formal parameter will change the actual parameter also,because both of them are pointing to the same memory location.
Here  no copying is required.
 
The IN parameter is passe by reference,so we can't change the value of IN parameter inside the module,It acts as a constant,But the OUT and IN OUT parameters are passed by value,we can change the values of OUT &  IN OUT paremeters

samareshp

  • Apr 17th, 2009
 



In Parameter:: call by reference
OUT Parameter: call by value
IN OUT Parameter: call by value


if you use the hint NOCOPY  with OUT Parameter and IN OUT Parameter then ::: call by reference

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions