Computer Science: An Overview: Global Edition (12th Edition)

Published by Pearson Higher Education
ISBN 10: 1292061162
ISBN 13: 978-1-29206-116-0

Chapter 6 - Programming Languages - Chapter Review Problems - Page 326: 32

Answer

See explanation

Work Step by Step

In passing parameters by address we do not provide the variable directly to the function instead we give the address of the variable to the function which can be used to access the variable. For example in following function the variable is passed by address and to print the variable stored at that address we have used the & operator also any changes made by using the & operator will also change the original variable but changes without & operator will have no effect so the final value of original variable will become 1: fun(Y): $\space \space \space \space$print(&Y) $\space \space \space \space$&Y=1 $\space \space \space \space$Y=3 When the parameters are passed by value a copy of them is created and that is used in the local scope of the function and the value of original variable remains unchanged. For example in the following function Y is passed by reference and a copy of original variable is created and no changes were reflected in original variable. fun(Y): $\space \space \space \space$Y=10 $\space \space \space \space$print(Y)
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.