FORTRAN Constants and Variables

  1. Credits for Lecture and Authoring
  2. Computer Language
  3. Contents of Fortran Programming
  4. FORTRAN Characters
  5. FORTRAN Chars Defined
  6. FORTRAN Numbers
  7. Integers
  8. Reals
  9. FORTRAN Variables
  10. FORTRAN Variable Rules
  11. FORTRAN Expression
  12. Ex: Expressions
  13. FORTRAN Hierarchy
  14. FORTRAN Hierarchy Def'n
  15. FORTRAN Program
  16. Assignment Statement (cont'd)
  17. Ending the Program

Credits for Lecture and Authoring

Lecture written by: Prof Martha Selby
Authored for presentation by: Mark Sobek
Revised by: John Even
Converted to HTML by: William Hart

Computer Language

A set of characters and rules governing the use of the characters for communication with a computer.


  1. FORTRAN (Formula Translation)
  2. C
  3. COBOL
  4. Etc.
A FORTRAN program consits of a series of:
  1. FORTRAN statements (Instructions) Utilizing various
  2. FORTRAN expressions formed by various combinations of
  3. FORTRAN constants and
  4. FORTRAN variables constructed from a set of
  5. FORTRAN characters

FORTRAN Characters

Characters are available to the program writer to fomulate:

  1. Numbers
  2. Variables
  3. Expressions

FORTRAN Characters Defined

  1. All uppercase and lowercase letters (A-Z, a-z)
  2. The numerals 0 through 9
  3. The following special characters:
    = Equal sign	 	, Comma			: Colon 
    + Plus sign		. Period		< Left angle bracket
    - Minus sign		' Apostrophe		> Right angle bracket
    * Asterisk		" Quotation Mark	% Percent sign 
    / Slash			$ Dollar sign		& Ampersand
    ( Left Parenthesis	_ Underscore		< TAB >Tab key
    ) Right Parenthesis	! Exclamation Point	< Space > Space Char


FORTRAN numbers can be either

  1. Integer
  2. Real

  1. Integer
    Contains no decimal point.
    Contains no fractional values
    Generally used as counters in looping processes.
    Computer truncates and reduces results to next lower integer in an integer division (4/3=1, 17/5=3)
  2. Real
    Contains a decimal point
    May be expressed in either of two forms
    	 Without an exponent (eg. 123.4)
    	 With an exponent (eg 0.1234E 03)

FORTRAN Variables

FORTRAN variables are quantities that are given names & whose values vary during program execution.

Five types of variables exist:

  1. Integer variables
  2. Real variables
  3. Character (discussed later)
  4. Logical (discussed later)
  5. Complex (not covered in this course)

The term "integer" and "real" carry the same meaning for both FORTRAN variables and FORTRAN numbers.

FORTRAN Variable Rules

  1. The first character of a FORTRAN variable must be a letter.
  2. Subsequent characters may be any combination of letters and digits. Special characters are not allowed.
  3. No more than six (6) characters may be used in a variable name.
  4. Blank spaces are not counted.
  5. Unless explicitly declared otherwise, an integer variable must begin with I, J, K, L, M, or N and a real variable must begin with one of the remaining alphabetic characters.
  6. Only one name may be used for each FORTRAN variable.
  7. Before a variable name can be used in computation, it must be assigned a value!
  8. FORTRAN vocabulary words are not allowed (READ, WRITE, STOP, etc.)

FORTRAN Expression

A FORTRAN expression is any mathematical relationship of FORTRAN constants and variables .

FORTRAN Hierarchy

The order in which a FORTRAN program performs mathematical operations.

FORTRAN Hierarchy Defined:

  1. Clear parentheses, scanning from left to right, clearing from left to right.
  2. Exponentiation, scanning from left to right, exponentiating from right to left. Hence Y=A**B**C is the same as Y=A**(B**C).
  3. Multiplication and/or division left to right.
  4. Addition and/or subtraction and/or negation left to right.


A FORTRAN program is made up of a series of instructions called statements.

Arithmetic assignment statement:

A particular type of statement that assignes the results of a numerical computation to a named FORTRAN variable.



Upon encountering this statement, the computer evaulates the FORTRAN expression , assigns the value to the variable and then stores Y in a predefined location in the computer's memory.

Ending the Computer Program

Following the last executable FORTRAN statement in a computer program, a "STOP" statement may be included. This terminates the execution of the program.

The last statement in a computer program must be an "END" statement. This terminates the compilation. If no STOP statement is included, one will be assumed when the END statement is reached.