Confused about use of double | Sololearn: Learn to code for FREE!
+ 1

Confused about use of double

int x = 10; double y = 20; can I use int instead of double

1st Apr 2017, 5:54 AM
Rakesh Chandra Dash
Rakesh Chandra Dash - avatar
1 Answer
+ 19
int is used for whole numbers, and double is for numbers with decimal values. If y will ever be assigned a number with a decimal (like 20.5), you have to use double. But if not, use int.
1st Apr 2017, 5:57 AM
Tamra
Tamra - avatar