So lets say i try to divide 10 by 3 (10 / 3) and the answer should be 3.33333(3)
how can i make the code to get me 4 numbers after decimal (3.3333)?
and tell me what i have to include :).
i got this:
int square;
square = ((b * b) - (4 * a * c));
Thanks !
EDIT: sorry, did not see beginner's forum :S.. i am a beginner
You got to make "square" a double, so it can store decimals. Then, if you want it to display an excact number of decimals, use "setprecision()". For example:
10/3 will still be an integer division because 3 and 10 are both integers.
You need to use a double literal to make it a double: 10.0 / 3; ( the 3 will be promoted to a double automatically )