Answer the question
In order to leave comments, you need to log in
What value will this code output?
In Pascal, it’s not a boom boom at all, but you need to solve the problem. And then there are the pointers.
In general, who can, tell me what value this code will display.
p^:=3; q^:=2;
p^:=q^;
if p=q then p:=nil else if p^=q^ then q:=p;
if p<>q then q^:=8;
writeln(p^);
Answer the question
In order to leave comments, you need to log in
p^ - means access not to the address, but to the value at this address.
At first, p and q have different knowledge. Then both becomes equal to 2
. q is not equal to p, then if their values are equal (and they are equal in 2), then q now has the same address as p.
Further, their addresses are the same. So the answer is 2.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question