Thread: Code to convert temperature

  1. #1
    Registered User
    Join Date
    Oct 2002

    Code to convert temperature

    //How to convert temperature from fahrenheit to celsius or vice versa

    #include <stdio.h>
    int main()
    double cel;
    for(int i=32; i<=212; i++)
    cel = (.555)*(i-32);
    printf( The degree "i" farenheit would be "cel" in celsius);

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    1) You have an incorrect number of { and }. For every { there is one and only one }. Without it, you have a problem.

    2) Use correct indenting and your code is much easier to read. Common practice is to indent one step for each { and to un-indent one step for each }.

    3) As per the previous thread you have, you know how to use printf, so how about you use it correctly and put in some format speficiers. %d and %f come to mind...

    Hope is the first step on the road to disappointment.

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Visalia, CA, USA
    I'm sure this is a homework assignment. And I'm sure that you are supposed to fix the errors. I don't want to condone cheating but this algorithm is everywhere on the internet. Just go to google.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 03-10-2009, 11:05 PM
  2. Explain this C code in english
    By soadlink in forum C Programming
    Replies: 16
    Last Post: 08-31-2006, 12:48 AM
  3. Replies: 14
    Last Post: 11-23-2005, 08:53 AM
  4. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM