Ask Question

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.

+4
Answers (1)
  1. 30 September, 03:25
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers