(a) Fortran originally had three kinds of GoTo statements. One was the unconditi
ID: 3572811 • Letter: #
Question
(a) Fortran originally had three kinds of GoTo statements. One was the unconditional GOTO, which jumped to a specified statement number. Another was the assigned GOTo, which we explored in Assignment 1. What is the name of the third kind of GoTO in original Fortran? (b) Was this statement removed from Fortran in Fortran 95? If not, was it removed in Fortran 2003? (c) Describe the syntax of this statement. (d) Describe the semantics of this statement. e) This kind of GoTo can be used to implement a multiple-selection construct. Use this statement to convert the Java switch statement of problem 4(a) into original Fortran. Since original Fortran supports only uppercase letters, use I and J as the variable names.Explanation / Answer
Third kind of GOTO statement is Computed GOTO statement.
yes, GOTO statements were removed during fortran 95
The syntax of the Computed GOTO statement is : GO TO (s [,s]...) i
where:
i is an integer expression
s is the statement label of an executable statement that appears in the same program unit as the computed GO TO statement. The same statement label may appear more than once in the same computed GO TO statement.
Execution of a computed GO TO statement causes evaluation of the expression i. The evaluation of i is followed by a transfer of control so that the statement identified by the ith statement label in the list of statement labels is executed next, provided that 1 <= i <= n, where n is the number of statement labels in the list of statement labels. If i<1 or i>n, the execution sequence continues as though a CONTINUE statement were executed.
For example:
GO TO ( 40, 50, 60, 70 ), N
...
40 CONTINUE
...
50 CONTINUE
...
60 CONTINUE
:
In the above example:
If N equals one, then go to 40.
If N equals two, then go to 50.
If N equals three, then go to 60.
If N equals four, then go to 70.
If N is less than one or N is greater than four, then fall through to 40.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.