![]() |
decimal places
I created a program that converts centigrade to farehenheit, and I want to only print the answer to two decimal places. I can probably leave it as it is, since the problem doesn't ask to be formatted that way, but if get a problem that involves money, I would like to know how to do it.
Here's the problem, and the language is c: Code:
/* This program converts Centigrade to Farenheit. |
Read the documentation for printf, it will do exactly what you want.
|
Thanks a-j, I just had to put the formating in the printf statement like such:
Code:
printf("Temperature in Centigrade: %3.2f\nTempreture in Farenheitt: %3.2f\n", cent, far); |
man is your friend.
|
I probably should of mentioned that I was using visual studio, and am just a beginner at this.
I kind of knew that it had something to do with the printf statement, but I kept putting it in the wrong place, before % sign, which gave me some strange answers. |
All times are GMT -8. The time now is 12:20 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project