Next: MATMUL Intrinsic
Up: Random Number Generation
Previous: Random Number Generation
PROGRAM throw_dice
IMPLICIT NONE
INTEGER :: throw, r
CALL RANDOM_NUMBER(r)
! r is returned 0 <= r <= 1
! NINT(r*5) gives an integer between 0 and 5
throw = 1 + NINT(r*5)
PRINT*, 'die throw = ', throw
END PROGRAM
Next: MATMUL Intrinsic
Up: Random Number Generation
Previous: Random Number Generation
©University of Liverpool, 1997
Thu May 29 10:11:26 BST 1997Not for commercial use.