609 B
609 B
-
Suppose that the following declarations are in effect:.... a.
14
b.34
c.4
d.true
e.false
-
Suppose that
high
,low
, andmiddle
are all pointer variables of the same type, and thelow
andhigh
point to elements of an array. Why is the following statement illegal, and how could it be fixed?
middle = (low + high) / 2
The above statement is illegal because you can't add an int *
to an int *
. It can be made legal by casting low
and high
to numbers, performing the operation, then casting to a pointer.
middle = (int*) (((long) low + (long) high) / 2);