Ask Question
29 May, 10:13

Write a program, using the syntax of whatever language you like, that produces different behavior depending on whether pass-by-reference or pass-by-value-result is used in its parameter passing.

+5
Answers (1)
  1. 29 May, 12:46
    0
    '''

    #!/usr/local/bin/python3

    def add2x (x):

    print ("beginning of add2x, x = %d" % x)

    x + = 1

    print ("end of add2x, x = %d" % x)

    def add2y (y):

    print ("beginning of add2y, y = %d" % y[ 0 ])

    y[ 0 ] + = 1

    print ("end of add2y, y = %d" % y[ 0 ])

    if (__name__ = = "__main__"):

    x = [ 5 ]

    y = [ 5 ]

    print ("before add2x, x = %d" % x[ 0 ])

    add2x (x[ 0 ])

    print ("after add2x, x = %d/n" % x[ 0 ])

    print ("before add2y, y = %d" % y[ 0 ])

    add2y (y)

    print ("after add2y, y = %d" % y[ 0 ])

    '''
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program, using the syntax of whatever language you like, that produces different behavior depending on whether pass-by-reference or ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers