This preview shows page 1. Sign up to view the full content.
Unformatted text preview: algorithm box along with its parameters. Now let’s say that the calling unit (the part of the program that wants the contents of the two places exchanged) calls Swap with data1 and data2 as parameters. Now let’s say that data1 is stored in location 0002 and data2 is stored in location 0003 . They contain the values 30 and 40, respectively. Figure 8.7 shows the content of the message board when the parameters are passed by value and passed by reference. When a parameter is a value parameter, the subprogram knows to manipulate the value on the message board. When a parameter is a reference parameter, the subpro-gram knows to manipulate the contents of the address on the message board. Should the parameters for subprogram Swap be value or reference parameters? Swap (data1, data2) Swap (Integer item1, Integer item2) Integer temp Declare local variable Set temp to item2 Set item2 to item1 Set item1 to temp...
View Full Document
This note was uploaded on 01/13/2011 for the course CSE 1550 taught by Professor Marianakant during the Fall '10 term at York University.
- Fall '10