Temperature Conversion code problems
I cannot seem to get the program to work correctly. I have tried to figure out whats wrong with the code but i got nothing, i am new to C programming any help will be much appreciated.
thanks a bunch!
Code:
#include <stdio.h>
void main()
{
float (temp_kelvin);
float (temp_celcius);
float (temp_farhenheit);
printf("Enter a temperature in Celcius:");
scanf_s("2f",&temp_celcius);
temp_kelvin = (temp_celcius + 273.15);
temp_farhenheit = (((1.8)*temp_celcius)+32);
printf("The equivalent Farhenheit temperature is: .2%f\n", temp_farhenheit);
printf("The equivalent Kelvin temperature is: .2%f\n", temp_kelvin);
}
still not working..new code
Code:
#include <stdio.h>
void main()
{
float temp_kelvin;
float temp_celcius;
float temp_farhenheit;
printf("Enter a temperature in Celcius: ");
scanf_s("2f",&temp_celcius);
temp_kelvin = (temp_celcius + 273.15f);
temp_farhenheit = ( ( (1.8) * temp_celcius) + 32);
printf("The equivalent Farhenheit temperature is: .2%f\n", temp_farhenheit);
printf("The equivalent Kelvin temperature is: .2%f\n", temp_kelvin);
}
thats what i got now and still not work. it gives the same incorrect temperatures no matter what starting celcius temperature i use. this is leading me to believe there is an error in the Code:
scanf_s("2f",&temp_celcius);
line possibly?