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.