Search unanswered questions...
Enter a question here...

How i can Write the program in fortran using goto statement?

[Edit]
The use of GOTOs in programming is generally considered to be bad form, because it very rapidly leads to "spaghetti code" where it is difficult or impossible to follow the program's logic flow.

However, given Fortran's comparatively weak set of flow controls, there are times when a GOTO is unavoidable or actually clearer than using a more-structured layout. A simple example would be a subroutine that checks its arguments for validity and exits immediately if it finds something incompatible. The alternatives would be

(A) Put a GOTO 99999 after each invalid condition is detected, where 99999 is the program's RETURN statement

(B) Set flags after each condition, falling through and checking more and more flags until you "naturally" reach the module's RETURN.

An example of (A) would be (using slight variations on Fortran 90 syntax)

subroutine foo(x,y)

implicit none

real*4 x, y

! Check for negative arguments

if (x < 0.0) then

print *, 'Argument X is negative'
goto 99999

endif

if (y < 0.0) then

print *, 'Argument Y is negative'
goto 99999

endif

! (Code body goes here ....)

99999 continue

return

end

Improve Answer Discuss the question "How i can Write the program in fortran using goto statement?" Watch Question

First answer by JayKay. Last edit by JayKay. Contributor trust: 1075 [recommend contributor]. Question popularity: 14 [recommend question]

Research your answer:

Answers.com > Wiki Answers > Categories > Technology > Computers > Computer Programming > How i can Write the program in fortran using goto statement?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
Program of jump statement?  What is goto statement in fortran language?  How do you use goto statement in c language?  How i can solve the problem in fortran using goto statement?  Write a Fortran program that can covert form yard to meter mile to km gallon to liter and pound to kg The program asks about the kind of conversion you wish to do and reads specific value converts?