HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to FortranVariablesOperatorsConditions (if)Loops (do)ArraysFunctions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
Variable (integer / real)parameter (constant)
🔢 Numbers & Math
🔁 Condition & Loop
📋 Array
🧩 Functions & Subroutines
Fortran›REFERENCE›Variables
📦

Variables

Typed variables and constants.

CommandDescription
Variable (integer / real)Typed variable declaration.
parameter (constant)Immutable constant.

Variable (integer / real)

Try it yourself →

Typed variable declaration.

Syntax

integer :: name
real :: name

Description

Variables are declared at the beginning of the program, BEFORE executable lines. integer is whole number, real is decimal, character is text. implicit none is a good habit.

Example

program h
  implicit none
  integer :: age
  real :: height
  age = 36
  height = 1.72
  print *, age, height
end program h

Expected output

36   1.72

When to use?

Storing all kinds of data.

Common mistakes

  • ⚠️ Declarations must be at the beginning of the code; new variables cannot be defined in between.

parameter (constant)

Try it yourself →

Immutable constant.

Syntax

real, parameter :: PI = 3.14

Description

Values defined with the parameter attribute cannot be changed.

Example

program h
  real, parameter :: PI = 3.14
  print *, PI
end program h

Expected output

3.14

When to use?

Constant values (pi, speed of light).

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code