C-14
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

C-14

  • 157 views
Uploaded on

 

More in: Education , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
157
On Slideshare
157
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
1
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Lecture 14Lecture 14 Version 1.0Version 1.0 Call by ReferenceCall by Reference
  • 2. 2Rushdi Shams, Dept of CSE, KUET, Bangladesh Methods to pass argumentsMethods to pass arguments  Arguments can generally be passed to functionsArguments can generally be passed to functions in one of the two ways:in one of the two ways: (a) sending the values of the arguments(a) sending the values of the arguments (b) sending the addresses of the arguments(b) sending the addresses of the arguments
  • 3. 3Rushdi Shams, Dept of CSE, KUET, Bangladesh Call by valueCall by value  ‘‘value’ of each of the actual arguments in thevalue’ of each of the actual arguments in the calling function is copied into correspondingcalling function is copied into corresponding formal arguments of the called functionformal arguments of the called function  changes made to the formal arguments in thechanges made to the formal arguments in the called function have no effect on the values ofcalled function have no effect on the values of actual arguments in the calling functionactual arguments in the calling function
  • 4. 4Rushdi Shams, Dept of CSE, KUET, Bangladesh Call by valueCall by value
  • 5. 5Rushdi Shams, Dept of CSE, KUET, Bangladesh Call by ReferenceCall by Reference  the addresses of actual arguments in the callingthe addresses of actual arguments in the calling function are copied into formal arguments offunction are copied into formal arguments of the called functionthe called function  using these addresses we would have an accessusing these addresses we would have an access to the actual arguments and hence we would beto the actual arguments and hence we would be able to manipulate themable to manipulate them
  • 6. 6Rushdi Shams, Dept of CSE, KUET, Bangladesh Call by ReferenceCall by Reference a 10 65000 b 20 60000 x 65000 70000 y 60000 75000 t 10 80000 20 10
  • 7. 7Rushdi Shams, Dept of CSE, KUET, Bangladesh Call by referenceCall by reference  Using a call by reference intelligently we canUsing a call by reference intelligently we can make a function return more than one value at amake a function return more than one value at a time, which is not possible ordinarilytime, which is not possible ordinarily
  • 8. 8Rushdi Shams, Dept of CSE, KUET, Bangladesh Call by referenceCall by reference
  • 9. 9Rushdi Shams, Dept of CSE, KUET, Bangladesh What is the output?What is the output?
  • 10. 10Rushdi Shams, Dept of CSE, KUET, Bangladesh What will be the output?What will be the output?
  • 11. 11Rushdi Shams, Dept of CSE, KUET, Bangladesh What will be the output?What will be the output?
  • 12. 12Rushdi Shams, Dept of CSE, KUET, Bangladesh What will be the output?What will be the output?