0
Why does the "int" command work for "x=10" but the writer used "double" for "y=20"?
5 Answers
+ 4
20 can be an int, float, double, or a string. It depends on how you intend to use it
+ 3
Definition:Ā A double is a largerĀ floatĀ typeĀ that holds both bigger and more precise numbers.
DoubleĀ variablesĀ are 8Ā bytesĀ in size. The range of values is from 2.2250738585072020Ć10ā308to 1.7976931348623157Ć10308
More importantly, theĀ precisionĀ of a double is 15 compared to 6 for a float. The precision of a number is how many digits (before and after the decimal point) it can store without errors occurring
+ 2
It wasn't required. I think they did that just for variety and to show you can do it. It's also interesting to note that the output stayed 20 and not 20.0 or something.
0
You can you int "y=20"; there is no problem with that ...double is mainly used for precise value .
- 6
cbdbf161c200192b21f25933fb92bc29af375f3d57b2297f7d497