Ask Question
2 August, 04:37

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.

+1
Answers (1)
  1. 2 August, 08:30
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers