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

# Formatted I/O in FORTRAN with syntax

Computer Programming · Chapter 11: Programming Language: FORTRAN

- Asked in: 2067 Asar, 4 marks
- Video: [Formatted read /write statement in FORTRAN](https://www.youtube.com/watch?v=8N6zuoBO_Jc) — Shrikant Harle
- 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-io-syntax
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-11

## Question

Describe the formatted input and output statement in FORTRAN programming language with its syntax.

## Short answer

Syntax: READ/WRITE(unit, label) list with a FORMAT(label) (descriptors). Descriptors like Iw, Fw.d, 'text', / control layout. Inline format strings e.g. '(I5,F8.2)' are allowed.

## Answer

Formatted I/O uses a FORMAT statement to control how the data appears.

**Syntax**
```fortran
      READ (unit, label) list
      WRITE (unit, label) list
label FORMAT (descriptor1, descriptor2, ...)
```
- `unit` is the device number (`*` is the default keyboard/screen); `label` is the number of the FORMAT statement; `list` holds the variables.
- The format can also be given inline: `WRITE(*,'(I5,F8.2)') N, X`.

**Edit descriptors**

| Descriptor | Use | Example |
|---|---|---|
| `Iw` | Integer in w columns | `I5` |
| `Fw.d` | Real, d decimals | `F8.2` |
| `Ew.d` | Real in exponent form | `E12.4` |
| `Aw` | Character | `A10` |
| `nX` | Skip n columns | `3X` |
| `'text'` | Literal text | `' TOTAL = '` |
| `/` | Next line | `/` |

**Example**
```fortran
      N = 25
      X = 3.14159
      WRITE(*,10) N, X
   10 FORMAT(' N = ', I4, '  X = ', F7.3)
```
Output: ` N =   25  X =   3.142`

## Check yourself

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

1. Which is the correct form of formatted output?
   A. WRITE (unit, label) list with label FORMAT (descriptors)
   B. PRINT label FORMAT list
   C. WRITE list label
   D. FORMAT (list) WRITE
   Answer: A. The WRITE names the unit and the FORMAT label, followed by the list of variables. (Key point: Syntax)

2. What does * as the unit mean?
   A. The default keyboard/screen
   B. A file named *
   C. A format
   D. Any file
   Answer: A. unit * is the default device (keyboard for READ, screen for WRITE). (Key point: Unit *)

3. What does F7.3 print for 3.14159?
   A. 3.14159
   B.   3.142
   C. 3.1
   D. 3.142 in 3 columns
   Answer: B. F7.3 is width 7 with 3 decimals, so 3.142 is right-aligned: '  3.142'. (Key point: Fw.d)

## Related in Computer Programming

- [Formatted and unformatted I/O in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-formatted-unformatted-io) — Computer Programming, chapter 11
- [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×
- [Define programming language](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Adefine-programming-language) — Computer Programming, chapter 1, asked 3×
- [Pattern: shrinking "Programming"](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Apattern-programming-shrinking) — Computer Programming, chapter 4
- [Two dimensional arrays in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-2d-array-syntax) — Computer Programming, chapter 11
- [High level languages; C versus FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Ahll-types-c-vs-fortran) — Computer Programming, chapter 1

## Related in other subjects

- [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×
- [Output for 5e^(jπn/3) input](https://www.bctengineer.com/question.md?key=semester_7%2Fdigital_signal_analysis_and_processing%3Alti-output-exp-pi3) — Digital Signal Analysis and Processing, chapter 3, asked 2×
