Introduction to Fortran

Simple Program Construction in Fortran » Declaring Variables

The only weather data needed for this program is the forecast high temperature. The high temperature is a number that could be an integer or a real number depending on your forecast information. Most websites and apps will report just the rounded value of the temperature. In Fortran, it makes a difference what type of number you will be given as each type of number would require a different variable definition. In Fortran, the numeric variable types are:

  • Integer,
  • Real, and
  • Double

Integers have no decimal values, reals have as much as 7 digits of precision, and doubles have up to 15 digits of precision. In computer models of atmospheric processes, the higher precision is important for our temperature, so these values will be stored as real or double.

Question 1 of 1

Which variable type should we use to define our forecast high temperature?

The correct answer is a.

Because the forecast high temperature is generally displayed as the integer value, using the integer type is best.

This may seem like a moot point, but this is part of the reason why Fortran code is still some of the fastest code out there for computing on large datasets. Hopefully, this burden of knowing our variable types upfront can be appreciated when the code runs faster than it would in other languages.

 program pick_outfit implicit none  integer high_temp  end 
Please make a selection.