FORTRAN Reference Manual
Intrinsic Functions
FORTRAN Reference Manual—528615-001
8-25
MOD Function
MOD Function
The MOD function returns the remainder of x divided by y.
The table below shows the argument and function type for the MOD generic function 
and its associated specific functions.
Considerations
•
The types of both arguments to MOD must be the same.
•
The value of MOD (x, y) is defined as
x - (INT(x/y) * y)
•
The result type of the MOD function is the same as the type of its arguments.
•
If y is zero, the function is undefined.
Example of the MOD Function
The program below uses MOD to print a blank line every fifth line:
DO 20, j = 1,100
 WRITE (*, 22) customer (k)
 IF (MOD (j, 5) .EQ. 0) THEN
 PRINT *, ' '
 END IF
20 CONTINUE
Syntax Argument Type Function Type
MOD (x, y)
MOD (x, y) Integer Integer
MOD4 (x, y) Integer*4 Integer*4
MOD8 (x, y) Integer*8 Integer*8
AMOD (x, y) Real Real
DMOD (x, y) Double Precision Double Precision
x and y are arithmetic expressions.










