Turing 019 — Real Variables

 

Remember that variables can be used to represent integer values such as 3 or 5, but integer variables cannot be used to store “floating point” values such as 4.5 or 1.27. For floating point variables, you would use the variable type “real”.

 

To use a real variable, you must declare it as follows:

 

var a : real

 

To assign a value to this variable you use an assignment statement similar to the following:

 

a := 4.5

Assignment

Create a program that assigns the value 3.1416 to a variable called "pi", then prints "The value of pi is <value of pi>".

 

 

Save as "019.t".