How can i print the value of "1/998001" in cpp or c? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can i print the value of "1/998001" in cpp or c?

When i try to to do that with double it always shows 0.00000... by default how can i fix that? https://code.sololearn.com/ccqFX6jGd45a/?ref=app

31st Mar 2017, 11:00 PM
Fuat Seven
Fuat Seven - avatar
2 Answers
+ 17
1/998001 is doing integer division because both sides are whole numbers. Add a .0 to the end of either number to get a double. When I tried it, though, the result was printed in scientific notation since it's such a small number.
31st Mar 2017, 11:36 PM
Tamra
Tamra - avatar
+ 1
i should have guess that thank you so much
31st Mar 2017, 11:38 PM
Fuat Seven
Fuat Seven - avatar