Computer science: value parameter vs variable parameter

Tutoring computer science, the difference between variable and value parameters is interesting. The tutor illustrates it.

value parameter:

the parameter’s value is sent to the function or method, but the function can’t change the parameter itself. For instance:

j=5

function(value_parameter p){

p=p+1;

output “p=” p;
output “j=” j;
}

function(j);

will give the output

p=6
j=5 //j is still 5

variable parameter

the parameter itself is sent to the function. Changes made to it by the function will persist in the external program.

j=5

function(variable_parameter p){

p=p+1;

output “p=” p;
output “j=” j;
}

function(j);

will give the output

p=6
j=6 //j has been changed to 6 by the function

Source:

docwiki.appmethod.com

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Tagged with:

Leave a Reply