Identify which of the following assignments are unsafe.

Question 8

Q10. Using the declarations of Problem 8, identify which of the following assignments are unsafe (where there may be loss of data);

  1. sh = intval
  2. intval = longval
  3. sh = ch

Ans.(a). unsafe because if sizes of short and int differ, there may be loss of data.

Ans.(b). unsafe because if sizes of int and long differ, there may be loss of data.

Ans.(c). safe, short is always larger than char.

Leave a Reply

Your email address will not be published. Required fields are marked *

64 Views
%d bloggers like this: