- Asked 3/16
- 2074 Chaitra · 3 marks
- 2070 Asar · 2 marks
- 2069 Asar · 2 marks
Data types in FORTRAN
Short answer
Standard data types: INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, CHARACTER. Implicit typing makes variables starting with I–N integer, others real; explicit declarations override this and must come before executable statements.
What are the different data types in FORTRAN?
Every variable and constant in FORTRAN has a data type, which decides its storage and the operations allowed. The standard types are:
| Type | Declaration | Meaning and example |
|---|---|---|
| INTEGER | INTEGER N, COUNT | Whole numbers, no decimal point: 25, -7 |
| REAL | REAL X, AREA | Numbers with fractional part (single precision, about 7 digits): 3.14, -0.5, 2.5E3 |
| DOUBLE PRECISION | DOUBLE PRECISION D | Real numbers with about twice the digits (about 15): 3.14159265358979D0 |
| COMPLEX | COMPLEX Z | Pair of reals (real, imaginary): (2.0, -3.5) |
| LOGICAL | LOGICAL FLAG | Only .TRUE. or .FALSE. |
| CHARACTER | CHARACTER*10 NAME | Text; *10 gives the length: 'NEPAL' |
Implicit typing. If a variable is not declared, its type is decided by its first letter: names starting with I, J, K, L, M or N are INTEGER, all other letters give REAL. IMPLICIT NONE (a common extension) turns this off and forces declarations. Declarations must come before executable statements.
INTEGER I, N
REAL X
LOGICAL OK
CHARACTER*8 CITY
CITY = 'POKHARA'
OK = .TRUE.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Sort array ascending in FORTRAN · Computer Programming, chapter 11 · asked 2×