So I've got this hw question and I'm pretty sure I'm missing it. I've got the notes I've read the relevant section in the book. But its still escaping me. So I'm going to post the question and my answer.
Let p be the following procedure, written using Ada syntax:
procedure P(X:
in out Integer; Y:
out Integer)
isbegin
I := I + 1;
X := X + 1;
Y := I + 1;
end P;
I is global to this procedure. Now, suppose that the following statements are executed:
I := 1;
A(1) := 10;
A(2) := 20;
A(3) := 30;
P(I, A(I));
For each of the following sets of assumptions, show the values of I, A(1), A(2), and A(3) after the call of P.
(a) X is passed by reference and Y is passed by reference
(b) X is passed by reference and Y is passed by result
(c) X is passed by value-result and Y is passed by reference
(d) X is passed by value-result and Y is passed by result
my answer:
1. I A(1) A(2) A(3)
a 3 11 20 30
b 3 10 20 31
c 2 11 20 30
d 2 10 21 30
again I'm pretty sure this is wrong but I wasn't in class the day we went over this stuff. (took papa to the ER, so it wasn't me just being lazy). And this teacher has a really bad habit of teaching in class and not mentioning it in the notes. Thanks if you can help. Or at least explain what I did wrong.
I would like to put something clever and about me but I fear my company will find it
Posts
The OP is absolutely fine and kosher under the H/A rules. He's asking for someone to help him with syntax, not to give him answers.
Sorry. Didn't mean to sound like a dick earlier. I just figured that the professor would be more help than random folks on the Internet.