This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Question 57. Select the valid primitive assignments of the following. A.int i = 10; char c = i; B.float f; long l = 100L; f = l; C.short s = 20; char c = s; D.byte b = 20; char c = b; E.short s1 = 10; short s2 = 20; short result = s1*s2; //I LIKE B ONLY, BUT ANSWER LIKES A AS WELL, HOW COME ?
Sarim, "B" is the only right anwer. The thumb rule is - Remember any other primitive other than a char, when assigned to char requires "EXPLICIT CASTING". int i = 10; char c = (char) i; The above compiles fine. HTH, Aruna
yes aruna is right it needs a explicit cast to convert from int to char. ------------------ Sachin, ************************************************** Learn from others mistakes. Life is too short to make all yourself. **************************************************
Sachin,<P>****************************************************<BR>Learn from others mistakes. Life is too short to make all yourself.<BR>****************************************************