- 2067 Asar · 4 marks
Formatted I/O in FORTRAN with 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.
Describe the formatted input and output statement in FORTRAN programming language with its syntax.
Formatted I/O uses a FORMAT statement to control how the data appears.
Syntax
READ (unit, label) list
WRITE (unit, label) list
label FORMAT (descriptor1, descriptor2, ...)
unitis the device number (*is the default keyboard/screen);labelis the number of the FORMAT statement;listholds 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
N = 25
X = 3.14159
WRITE(*,10) N, X
10 FORMAT(' N = ', I4, ' X = ', F7.3)
Output: N = 25 X = 3.142
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Formatted and unformatted I/O in FORTRAN · Computer Programming, chapter 11
- Formatted vs unformatted I/O · Computer Programming, chapter 4 · asked 4×
- Define programming language · Computer Programming, chapter 1 · asked 3×
- Pattern: shrinking "Programming" · Computer Programming, chapter 4
- Two dimensional arrays in FORTRAN · Computer Programming, chapter 11
- High level languages; C versus FORTRAN · Computer Programming, chapter 1
- Output of e^(−2t)u(t) to a rectangular input · Signals and Systems, chapter 5 · asked 4×
- CE configuration input/output characteristics · Basic Electronics Engineering, chapter 3 · asked 3×
- LTI output for h(t)=e^(-2t), rectangular input · Data Communication, chapter 2 · asked 3×
- Output for 5e^(jπn/3) input · Digital Signal Analysis and Processing, chapter 3 · asked 2×