+ 1
how to display millions
I can't display millions. For example car price = 1,470,000 insurance = 20580 roadtax= 12048 totalprice = 1.50263e+006 why the total price will be like that ? I used ' double ' for data type
2 Réponses
+ 9
Either use int or any other data type
Or you can simply use std::fixed
Here's the code
double carprice = 1470000;
double insurance = 20580;
double roadtax= 12048;
double totalprice = carprice+insurance+roadtax;
cout<<fixed<<totalprice;
This should give you the total price with proper decimals
+ 1
Thank you so much sir, you're really helpful. Have a nice day sir !