Hi,
I am a 1st year computer science student doing my degree by distance education.
I dont have anyone to bounce stuff off so any assistance would be really appreciated.
I have been asked the following question...............
The following is a program segment and the definition of a procedure named sub
x <- 3; procedure sub (y)
sub (x); y <- 5;
print value of x;
What value will be printed by the program segment if parameters are passed by value?
Now I am taking it that the left is the calling program ( X ) and right is the procedure (Y ). So , to pass by value, program X sends its value of 3 over to procedure Y which leaves the value as 3. So the value 3 will be printed.................... And if it was passed by reference then X would pass 3 over to Y which would add the 3 to its value of 5.......... giving us a value of 8 passed back to the program on the left, which would then print a value X of 8.............
Do I make sense?
And am I on the right track.
I do not want an answer. I just want to know if I understand, or not.