lastTemperature = 50 problem


I am trying to figure out why the static variable example of the temperature problem doesn’t say the last temperature converted was 50. Here is my code and then the output follows.

[code]#include <stdio.h>
#include <stdlib.h>

//Declare a static variable
static float lastTemperature;

//Initialize lastTemperature to 50 degrees
static float lastTemperature = 50.0;

float fahrenheitFromCelsius(float cel)
lastTemperature = cel;
float fahr = cel * 1.8 +32.0;
printf("%f Celsius is %f Fahrenheit\n", cel, fahr);
return fahr;

int main(int argc, const char * argv[])
float freezeInC = 0;
float freezeInF = fahrenheitFromCelsius(freezeInC);
printf(“Water freezes at %f degrees Fahrenheit\n”, freezeInF);
printf(“The last temperature converted was %f\n”, lastTemperature);



0.000000 Celsius is 32.000000 Fahrenheit
Water freezes at 32.000000 degrees Fahrenheit
The last temperature converted was 0.000000