Select a convenient declaration and initialization of a floating point number:

Việt Quân

New member
Select a convenient declaration and initialization of a floating point number:
A. float somevariable = 12.502D
B. float somevariable = (Double) 12.502D
C. float somevariable = (float) 12.502D
D. float somevariable = (Decimal)12.502D
 
Answer: c
Explanation: We cannot implicitly convert a “double” number directly to any other data type. Here, its float we have to add the required data type to number as :
Code:
float somevariable = (float)12.502D;
 or
Double somevariable = (Double)12.502D;
 

Tìm kiếm

Back
Top