Тhese are my calculations
float c = 5.0 * (12.0 - 32.0) / 9.0;
printf("%f.2", c);
Result is -11.111111.2 but I expected to be -11.11. What is wrong ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The format specifier should read
"%.2f".In what you have right now, the
.2is misplaced. This is why you get more digits than expected, and why the.2appears verbatim at the end of the output.