Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C Program

  1. Feb 3, 2009 #1
    Okay. I need to write a C program to convert between fahrenheit and celsius degrees.
    Last edited: Feb 4, 2009
  2. jcsd
  3. Feb 3, 2009 #2


    User Avatar
    Science Advisor
    Homework Helper

    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
  4. Feb 3, 2009 #3
    What is the indication leading you to believe there is somethig wrong with your compiler? Also, which compiler product are you using?
  5. Feb 3, 2009 #4
    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"?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook