Q:

Although the following are legal, they probably do not behave as the programmer expects

0

Although the following are legal, they probably do not behave as the programmer expects. Why? Rewrite the expressions as you think they should be.

(a) if (p = getPtr() != 0)

(b) if (i = 1024)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

`if (p = getPtr() != 0)` is the same with `if (p = (getPtr() != 0))` and should be `if ((p = getPtr()) != 0)`.

`if (i = 1024)` may be `if (i == 1024)`.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now