---
title: "Data types in FORTRAN"
subject: "Computer Programming"
chapter: 11
key: "semester_1/computer_programming:fortran-data-types"
source: https://www.bctengineer.com/q/semester_1/computer_programming/fortran-data-types
site: BCT Engineering
---

# Data types in FORTRAN

Computer Programming · Chapter 11: Programming Language: FORTRAN

- Asked in: 2074 Chaitra, 3 marks; 2070 Asar, 2 marks; 2069 Asar, 2 marks (asked 3 times)
- Video: [Data Types & Variable Assignments | FORTRAN Tutorial - 4](https://www.youtube.com/watch?v=vpaCRk0P7uI) — PhyLosophy
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/fortran-data-types
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-11

## Question

What are the different 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.

## Answer

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.

```fortran
      INTEGER I, N
      REAL X
      LOGICAL OK
      CHARACTER*8 CITY
      CITY = 'POKHARA'
      OK = .TRUE.
```

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. If a variable KOUNT is not declared in FORTRAN 77, what is its type?
   A. REAL, because all undeclared are real
   B. CHARACTER
   C. INTEGER, because it starts with K (I to N)
   D. LOGICAL
   Answer: C. Undeclared names starting with I, J, K, L, M or N are INTEGER; all other first letters give REAL. (Key point: Implicit typing)

2. What does IMPLICIT NONE do?
   A. Turns off first-letter typing so every variable must be declared
   B. Makes all variables integers
   C. Removes all constants
   D. Makes variables double precision
   Answer: A. It disables implicit typing and forces declarations of all variables. (Key point: IMPLICIT NONE)

3. How does DOUBLE PRECISION differ from REAL?
   A. It stores only integers
   B. It stores text
   C. It stores about twice the digits (about 15 instead of about 7)
   D. It stores only .TRUE. or .FALSE.
   Answer: C. Double precision keeps roughly twice as many significant digits as single-precision REAL. (Key point: DOUBLE PRECISION)

## Related in Computer Programming

- [Sort array ascending in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-sort-ascending) — Computer Programming, chapter 11, asked 2×
