- #1
Taylor_1989
- 402
- 14
Hi guys, I am having trouble seeing where I have actually gone wrong with my code. If I run the code I am getting approximation of 12 as my lowest is way to big. But I am really struggling to find where I have gone wrong. Any advice would be appreciated.
Fortran:
PROGRAM assign_10_1
IMPLICIT NONE
INTEGER, DIMENSION (1:12) :: SEED
REAL:: A,X,Y
INTEGER:: I, N, COUNTER_CIRCULE, COUNTER_SQUARE
COUNTER_CIRCULE=0
COUNTER_SQUARE=0
N=100000
WRITE(*,*)'please seclect 12 numbers for your seed'
READ(*,*) SEED
WRITE(*,*) SEED
CALL RANDOM_SEED(PUT=SEED)
DO I=1,N
CALL RANDOM_NUMBER(X)
CALL RANDOM_NUMBER(Y)
WRITE(*,*) X,Y
IF (X**2+Y**2 < 1) THEN
COUNTER_CIRCULE=COUNTER_CIRCULE+1
ELSE
COUNTER_SQUARE=COUNTER_SQUARE+1
END IF
END DO
A=4*(COUNTER_CIRCULE/COUNTER_SQUARE)
WRITE(*,*)'ESTIMATION FOR VALUE OF PI', A
END PROGRAM