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

    mgb_phys

    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"?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: C Program
  1. C Program (Replies: 5)

  2. C program (Replies: 4)

  3. C program (Replies: 4)

  4. C program (Replies: 0)

  5. C programming (Replies: 9)

Loading...