0
PROGRAM TRYY

implicit none

REAL:: x_value=2
REAL:: y_value=3
REAL:: answer

IF ((x_value >= 0 .AND. x_value < 10) .AND. (y_value >= 0 .AND. y_value < 10)) THEN
  answer = (1/3)*(x_value) + (1/2)*(y_value)
  WRITE(*,*) answer
ELSE
  WRITE(*,*)
END IF

STOP
END PROGRAM TRYY

This should read 2.16667, but instead it reads 0 because there are fractions in there. The fractions are (1/3) and (1/2). When I change them to 0.3 and 0.5 respectively, it gives me 2.1

I don't want that. I want (1/3) and (1/2) to work. What is happening?

Master
  • 59
  • 1
  • 2
  • 10

0 Answers0