In fixed-form Fortran, which token sequence is produced from the statement DO…
1999
In fixed-form Fortran, which token sequence is produced from the statement DO 10 I = 1.25?
Answer: A. DO10I, =, 1.25 — ConceptIn fixed-form Fortran, blanks outside character strings are insignificant. Lexical analysis first applies this source-form rule, then identifies…
- A.
DO10I,=,1.25 - B.
DO,10I,=,1.25 - C.
DO,10,I,=,1.25 - D.
DO,10,I,=,1,.,25
Attempted by 120 students.
Show answer & explanation
Correct answer: A
Concept
In fixed-form Fortran, blanks outside character strings are insignificant. Lexical analysis first applies this source-form rule, then identifies maximal lexemes such as identifiers, operators, and numeric literals.
Application
Remove the insignificant blanks from
DO 10 I = 1.25to obtainDO10I=1.25.DO10Iis one identifier,=is the assignment symbol, and1.25is one real literal.The resulting token sequence is
DO10I,=,1.25; it contains three tokens.
Cross-check and contrast
If the period were a comma, DO 10 I = 1,25 would be a DO-loop form and would tokenize differently. The period in the given line makes 1.25 a real literal and leaves DO10I as an identifier.
The sequence
DO,10I,=,1.25inserts a boundary at the first visible blank, although fixed-form blanks do not create such a boundary.The sequence
DO,10,I,=,1.25uses every visible blank as a mandatory boundary; this is the five-token interpretation.The sequence
DO,10,I,=,1,.,25additionally splits the real literal at its decimal point.
Result
Therefore, the produced token sequence is DO10I, =, 1.25, containing three tokens.
Explore the full course: Iocl Engineers Officers Grade A Paper 2