0
Why does the "int" command work for "x=10" but the writer used "double" for "y=20"?
5 ответов
+ 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