Thread: Please help converting Fahrenheit to Celsius

  1. #16
    Registered User
    Join Date
    Oct 2009
    Posts
    16
    Quote Originally Posted by RockyMarrone View Post
    hey victory1
    Why u stuck with for plz can u tell me that First

    fOR for loop() here in the code just replace


    while (start_temprature <= end_temprature) {
    with

    for (float temprature = start_temprature; temprature <= end_temprature; temprature+=5) {
    I'm just trying to finish my associates degree in programming. I'm a little bit older with two young children who require my attention all the time so I don't have hours to research and read my C programming book. I'm not looking for and easy out for this class, I love programming I just am having a hard time understanding the FOR statement that I have to use for this assigenment. The assignement that I have to do reads as follows.

    Write a C program that converts Fahrenheit to Celsius temp. in increments of 5 degrees. The initial value of the Fahrenheittemp. and the total conversions to be made are to be requested as user input during program execution.

    I really don't see the light when it comes to using the FOR statement but that is what my teacher requires me to use. I can think of different ways to do this program that would run just fine to but that is not what the teacher wants. Like I said I'm older and I took classes 10+ years ago like cobol, fortan DOS and advance DOS which I got all A and B's in these classes so I'm just a bit rusty at this.

  2. #17
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You have my sympathy, but you'll have to step it up - regardless. For loops are a very basic loop in C, used all the time, (in every language I've seen), and not hard to understand.

    Your assignment requires you to ask the user for the starting and ending temperature. That must be done before any for loop can start.

    Ask for a start temperature

    Ask for an ending temperature

    (these will both be in Fahrenheit)

    The you need your for loop:

    Something like:
    Code:
    for(i = startTemp; i <= stopTemp; i+=5) {
      c = (i * 5)/9 - 32
      printf() //print out "i = c", i, c
    }
    Your results will not be completely accurate, because integer division drops the fractional part of any division. If you need greater accuracy (to less than 1 degree), then you'll need to make all your variables floats or doubles.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 09-25-2009, 11:15 AM
  2. Conversion from Fahrenheit to Celsius problem
    By -Syntax in forum C++ Programming
    Replies: 5
    Last Post: 01-22-2008, 08:56 PM
  3. Please Help!!!
    By F1uT3 in forum C++ Programming
    Replies: 16
    Last Post: 06-24-2005, 01:20 PM
  4. celsius to fahrenheit conversion
    By chipster18 in forum C Programming
    Replies: 11
    Last Post: 03-26-2003, 07:38 AM