---
title: "Formatted and unformatted I/O in FORTRAN"
subject: "Computer Programming"
chapter: 11
key: "semester_1/computer_programming:fortran-formatted-unformatted-io"
source: https://www.bctengineer.com/q/semester_1/computer_programming/fortran-formatted-unformatted-io
site: BCT Engineering
---

# Formatted and unformatted I/O in FORTRAN

Computer Programming · Chapter 11: Programming Language: FORTRAN

- Asked in: 2071 Shrawan, 8 marks
- Video: [FORTRAN Formatted Input Output](https://www.youtube.com/watch?v=R91Ojgm18uw) — Sanjay Adhau
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/fortran-formatted-unformatted-io
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-11

## Question

What do you mean by formatted and unformatted input/output statements in Fortran and also give suitable example which explain the concept of Formatted I/O?

## Short answer

Formatted I/O uses a FORMAT statement with edit descriptors (e.g., 2I4) to control output; example: WRITE(*,20) L,B. Unformatted I/O uses READ * (list‑directed) or binary file I/O without a format.

## Answer

#### Formatted input/output
In formatted I/O the programmer controls the exact form of the data by a **FORMAT** statement (edit descriptors) referred to by a label in `READ` or `WRITE`. Data are converted between their internal form and readable text.

Syntax: `WRITE(unit, label) list` and `label FORMAT(descriptors)`

Common descriptors: `Iw` integer, `Fw.d` real with d decimals, `Ew.d` exponent form, `Aw` character, `nX` n blanks, `/` new line, and quoted text.

#### Unformatted input/output
- **List-directed (free format):** `READ *, A, B` and `PRINT *, A, B` (or `READ(*,*)`) do not use a FORMAT. The computer decides the layout, with values separated by blanks or commas. Many textbooks call this unformatted I/O.
- In the strict sense, **unformatted I/O** means writing and reading the internal binary form to a file (`OPEN(..., FORM='UNFORMATTED')`, then `WRITE(10) list`). It is fast, with no conversion, but not readable by people.

#### Example of formatted I/O
```fortran
      PROGRAM RECT
      INTEGER L, B
      REAL A
      READ(*,10) L, B
      A = L * B
      WRITE(*,20) L, B, A
   10 FORMAT(2I4)
   20 FORMAT(' LENGTH =', I4, '  BREADTH =', I4, /, ' AREA =', F8.2)
      STOP
      END
```
For input `  12   5` the output is
```text
 LENGTH =  12  BREADTH =   5
 AREA =   60.00
```
`2I4` reads two integers of width 4, `F8.2` prints a real in 8 columns with 2 decimals, and `/` starts a new line.

## Check yourself

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

1. What controls the exact form of data in formatted I/O?
   A. A FORMAT statement with edit descriptors
   B. The compiler
   C. The * unit
   D. The OPEN statement only
   Answer: A. A label in READ/WRITE refers to a FORMAT statement that describes the layout. (Key point: Formatted I/O)

2. What is READ *, A, B called?
   A. Formatted with F descriptors
   B. List-directed (free-format) input
   C. Binary input
   D. An error
   Answer: B. No FORMAT is used; the computer decides the layout. Many textbooks call this unformatted I/O. (Key point: List-directed)

3. In the strict sense, what is unformatted I/O?
   A. Reading and writing the internal binary form to a file without conversion
   B. Printing text with no spaces
   C. Using I descriptors only
   D. Using READ *
   Answer: A. FORM='UNFORMATTED' files hold binary data: fast but not readable by people. (Key point: Strict unformatted)

4. In the example, what do 2I4 and F8.2 do?
   A. 2I4 reads two integers of width 4; F8.2 prints a real in 8 columns with 2 decimals
   B. 2I4 prints 2 reals; F8.2 reads integers
   C. Both print text
   D. 2I4 prints 4 integers
   Answer: A. I4 is an integer of width 4, repeated twice; F8.2 means width 8 with 2 decimals. (Key point: Descriptors)

## Related in Computer Programming

- [Formatted vs unformatted I/O](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aformatted-vs-unformatted-io) — Computer Programming, chapter 4, asked 4×
- [Formatted I/O in FORTRAN with syntax](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-formatted-io-syntax) — Computer Programming, chapter 11
- [Pattern: PULCHOWK using unformatted output](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Apattern-pulchowk) — Computer Programming, chapter 4
- [Output of printf statements](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aprintf-output-a-b) — Computer Programming, chapter 4
- [Pattern N, eee, PPPPP using unformatted I/O](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Apattern-n-e-p-a-l) — Computer Programming, chapter 4

## Related in other subjects

- [Four-quadrant multiplier: concept and output](https://www.bctengineer.com/question.md?key=semester_4%2Fadvanced_electronics%3Afour-quadrant-multiplier-concept) — Advanced Electronics, chapter 6
- [Output of e^(−2t)u(t) to a rectangular input](https://www.bctengineer.com/question.md?key=semester_4%2Fsignals_and_systems%3Aconvolution-exponential-rect-input) — Signals and Systems, chapter 5, asked 4×
- [CE configuration input/output characteristics](https://www.bctengineer.com/question.md?key=semester_2%2Fbasic_electronics_engineering%3Ace-npn-characteristics) — Basic Electronics Engineering, chapter 3, asked 3×
- [LTI output for h(t)=e^(-2t), rectangular input](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Alti-output-rect-input) — Data Communication, chapter 2, asked 3×
