0
Why the output for x is 0 ?
2 Respostas
+ 3
Use float or double if you need precision. Int contains whole numbers, so in division the precision is "cut off".
+ 3
What you should do to avoid it are two things:
1. Declare x as float or double
2. Write the division expression with at least one of the arguments as a floating point number, like this:
https://code.sololearn.com/clZkvxVW7Hl7/?ref=app
Also, feel free to refresh the lesson on the division operator:
https://www.sololearn.com/learn/CPlusPlus/1609/