1)

Which of the following statement is a convenient declaration and initialization of a floating point number:


A) float variable = 22.502D

B) float variable = (Double) 22.502D

C) float variable = (float) 22.502D

D) float variable = (Decimal)22.502D

Answer:

Option C

Explanation:

We cannot implicitly convert a “double” number directly to any other datatype. Here, we have to cast the double number as float.


float somevariable = (float)22.502D;
or
Double somevariable = (Double)22.502D;