ICSE Class 10 Computer Applications
Question 13 of 25
Values and Data Types — Question 13
Back to all questions 13
Question Question 13
What is wrong with the following statement?
float flt = 7895.0345;
This statement is trying to assign a double literal to a float variable so it will result in a syntax error of incompatible types (possible lossy conversion from double to float). To fix it we need to a f or F at the end of the double literal to make it a float literal as shown below:
float flt = 7895.0345f;