PRO
睿宏
asked

Expert
Abhay Jajodia answered
Hi 睿宏,
That happens because printf("%f", ...) shows 6 digits after the decimal by default, so 78.32 becomes 78.320000.
If you want only 2 decimal places, set the precision like this:
printf("%.2f", number);
If you have more questions, I am here to help 😊
C
This question was asked as part of the Learn C Programming course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer