I am making a small program that converts a celsius temperature to Fahrenheit and Kelvin degrees It uses a function which takes a pointer to int as argument and returns Fahrenait.When the program is over i have to change the value of akc integer which is where i save the celsius temperature to kelvin degrees Here is what i have done.
float thermo(int *);
int main(){
int akc;
akc=100;
printf("%dce = %f = %dK\n",akc,thermo(&akc),akc);
system("pause");
return 0;
}
float thermo(int *akc){
float a=*akc;
*akc+=273;
return 9*a/5+32;
}
My problem is that when i print all the values i get the following output:
373 celsius = 212.000000 Fahrenheit = 100Kelvin
but the result should be
100 celsius = 212.000000 Fahrenheit = 373Kelvin
Any ideas?