[cs13001] Tech Career Expo

Mikhail Nesterenko mikhail at cs.kent.edu
Tue Mar 5 17:27:07 EST 2013


> 
>  I was going thought the sample test and ur explanation from class and was
> wondering in question 6
> You said in class the output would be 3,5,4,5 for abcd respectively now I
> was wondering for c is the output not going to be 3 since it is being
> passed by value ?

"c" is assigned the return value of function1(). The argument for
function1() is "a" whose value is 3. The function definition
increments the parameter (to 4) and returns it.

Hence, "c" is assigned 4. 

That is, the parameter is passed-by-value. Hence, the argument is not
affected by the updated value of the parameter. Yet, the function's
return value is based on the updated value of the parameter.

Thanks,
-- 
Mikhail


More information about the cs13001 mailing list