Thread: Temperature convertor

  1. #1
    Registered User
    Join Date
    Sep 2017
    Posts
    41

    Temperature convertor

    I keep getting -1 for both degreek and degreeF and I don't seem to figure out what I'm missing here please help!



    Code:
    #include <stdio.h>
    
    float convertKtoF(float);
    
    
    void main (void)
    {
        float degreeK ;
        float degreeF;
    
    
        printf("please enter a temperature in degrees Kelvin\n");
        scanf("%f", &degreeK);
    
    
        degreeF = convertKtoF(degreeK) ;
    
    
        printf("Kelvin: %f\t" , &degreeK);
        printf("Fahrenheit: %f" ,&degreeF);
    
    
    
    
    
    
    }
    //*---------------------------------------------------------------------
    
    
    
    
    float convertKtoF(float TK)
    {
        float degreeC;
        float degreeF;
        // Variable declarations
    
    
        // Instructions
        degreeC = TK - 273.2 ;
        degreeF =(degreeC * 9/5) + 32;
        return degreeF;
    }

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Your first problem is that you don't need the ampersand in front of the variables in your printf() call.

    Jim

  3. #3
    Registered User
    Join Date
    Sep 2017
    Posts
    41
    yeah thanks man I don't know how I overlooked that, it works now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [First Program] Base Convertor
    By cwn723 in forum C++ Programming
    Replies: 5
    Last Post: 05-06-2010, 06:25 PM
  2. morse code convertor
    By neandrake in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2004, 10:53 AM
  3. Currency Convertor
    By Dangerous Dave in forum C Programming
    Replies: 1
    Last Post: 11-14-2003, 06:44 AM
  4. Java 2 C# convertor
    By aym_7 in forum C# Programming
    Replies: 2
    Last Post: 06-03-2002, 06:07 AM
  5. c++ to c convertor
    By kendals in forum C++ Programming
    Replies: 3
    Last Post: 03-19-2002, 07:02 PM

Tags for this Thread