

* euclid.f (FORTRAN 77) * Find greatest common divisor using the Euclidean algorithm PROGRAM EUCLID PRINT *, 'A?' READ *, NA IF ( NA. Comment lines may be indicated with either a C or an asterisk ( *) in column 1. A zero in this position advances two lines (double space), a 1 advances to the top of a new page and + character will not advance to a new line, allowing overprinting.Īs of FORTRAN 77, single quotes are used to delimit character literals, and inline character strings may be used instead of references to FORMAT statements. The space immediately following the 13H is a carriage control character, telling the I/O system to advance to a new line on the output. (Some compilers also supported character literals enclosed in single quotes, a practice that came to be standard with FORTRAN 77.) The initial 13H in the FORMAT statement in the above example defines a Hollerith constant, here meaning that the 13 characters immediately following are to be taken as a character constant (note that the Hollerith constant is not surrounded by delimiters). If execution flows into a FORMAT statement, it is a no-op thus, the example above has only two executable statements, WRITE and STOP. Typically a FORMAT statement is placed immediately following the WRITE statement which invokes it alternatively, FORMAT statements are grouped together at the end of the program or subprogram block. FORMAT statements may be placed anywhere in the same program or function/subroutine block as the WRITE statements which reference them. The number 7 in the WRITE statement refers to the statement number of the corresponding FORMAT statement. (The card reader or keyboard was usually connected as unit 5). This program prints "HELLO, WORLD" to Fortran unit number 6, which on most machines was the line printer or terminal. In either condition, a message will be printed.Ĭ FORTRAN IV WAS ONE OF THE FIRST PROGRAMMING C LANGUAGES TO SUPPORT SOURCE COMMENTS WRITE ( 6, 7 ) 7 FORMAT ( 13 H HELLO, WORLD ) STOP END This program has two input checks in the READ statement with the END and ERR parameters, one for a blank card to indicate end-of-data and the other for zero value along with valid data. 0 ) GO TO 90 S = ( A + B + C ) / 2.0 AREA = SQRT ( S * ( S - A ) * ( S - B ) * ( S - C ) ) WRITE ( 6, 601 ) A, B, C, AREA GO TO 10 50 WRITE ( 6, 602 ) STOP 90 WRITE ( 6, 603 ) STOP END Simple Fortran 77 program Edit 2, $ 13 H SQUARE UNITS ) 602 FORMAT ( 10 HNORMAL END ) 603 FORMAT ( 23 HINPUT ERROR, ZERO VALUE ) INTEGER A, B, C 10 READ ( 5, 501 ) A, B, C IF ( A. No specific units are stated.Ĭ AREA OF A TRIANGLE - HERON'S FORMULA C INPUT - CARD READER UNIT 5, INTEGER INPUT, ONE BLANK CARD FOR END-OF-DATA C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT C INPUT ERROR DISPAY ERROR MESSAGE ON OUTPUT 501 FORMAT ( 3 I5 ) 601 FORMAT ( 4 H A =, I5, 5 H B =, I5, 5 H C =, I5, 8 H AREA =, F10. Normal output will be one line printed with A, B, C, and AREA.
Fortran 90 write format code#
If one of the input values is zero, then the program will end with an error code of "1" in the job control card listing following the execution of the program.
Fortran 90 write format free#
Some compilers also offer free form source by using a compiler flagĪrea Of a Triangle program Edit Simple Fortran II program Edit If errors are produced when you compile your FORTRAN code, first check the column alignment. the line-length may be limited to 72 characters (derived from the 80-byte width of a punch-card, with last 8 characters reserved for (optional) sequence numbers).continuation lines must have a non-blank character in column 6.statement labels must occur in columns 1-5.

