Converting Fahrenheit & Celsius: A C Programming Guide

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 3K views
queenspublic
Messages
59
Reaction score
0
Okay. I need to write a C program to convert between fahrenheit and celsius degrees.
 
Last edited:
Physics news on Phys.org
Have you asked the computer?
Off the top of my head;
The main definition is wrong - it might compile but it's wrong.
You probably want to use floating point numbers rather than integers
Your tests for 'c' and 'f' don't do what you think they do
 
What is the indication leading you to believe there is somethig wrong with your compiler? Also, which compiler product are you using?
 
The line beginning with "printf("%d degrees celsius" is missing a semicolon.

You should not say something like 5 / 9 in C. Division in an integer expression will round down, such that 5 / 9 = 0. Say something more like 5.0 / 9.0, or promote "degrees" to a float, so that the compiler knows to use floating point math.

Also maybe some compilers will complain that there is no return type for main().

You should try to get your compiler working. As potential asks, what do you mean "something is wrong with it"?