How do you print out decimals in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do you print out decimals in c++

31st Dec 2016, 4:55 PM
Papa Dadze Dadson
Papa Dadze Dadson - avatar
3 Answers
+ 10
Use "double" for up to 15 decimals or "float" for up to 7 decimals. If you'd like your answer to be a decimal number place a "." after the number (x=10./3.;) or type "(float)" before the variable (x= (float) 10/3;).
31st Dec 2016, 5:20 PM
Bodan Talev
Bodan Talev - avatar
+ 2
Come to my room
27th Mar 2017, 2:24 AM
Enoch Ewusi Hagan
Enoch Ewusi Hagan - avatar
+ 1
use double or float...
31st Dec 2016, 5:14 PM
Dhairya Karna
Dhairya Karna - avatar