0
votes

I am at the beginning with my studies and would like to ask a question regarding a function in pascal. The aim is to calculate the Fahrenheit value in Celsius. The formula is as follows: C = [5 * (F - 32)] / 9.

The user should put in his value and it should result in the correct number. My program is so far:

Program Temperaturerrechnung (input, output);  
var  
C: real;  
F: real;  
begin  
    writeln('Insert Fahrenheit', F);  
    readln(F);  
    C:= (5 * (F - 32)) / 9  
    writeln('The temperature is C: ', C)  
end  

When compiling, it tells me that F has not identified.

1
I think you can't readLn into a real variable. You'd have to have a separate text variable and then cast it to real (don't remember the syntax for that, though... it might be StrToFloat depending on which version of Pascal you are using) - Pekka
Works fine with Free Pascal after adding a semicolon after the " / 9 ". If you have problems entering data and you are in a locale with a comma as decimal separator, try to use point as decimal separator too - Marco van de Voort

1 Answers

3
votes

You have a few problems there:

writeln('Insert Fahrenheit', F);

The F variable is not initialized here, that means you have never assigned it a value. In this case I believe you don't want it in the output at all:

writeln('Insert Fahrenheit');

Also, you are missing ; after C:= (5 * (F - 32)) / 9.