program distances !Subroutine distances(x1,y1,x2,y2,x3,y3,d1,d2,d3) !Subroutine to calculate three distances between three points. !Variables used are: !A(x1,y1),B(x2,y2),C(x3,y3) are the coordinates of three points. !d1: the distance between A and B !d2: the distance between A and B !d3: the distance between A and B !Input:The points A,B,C !Output:The distances between A and B, B and C,C and A !Variable declerations real:: x1,x2,x3,y1,y2,y3,d1,d2,d3,a1,a2,a3 !Read the coordinates of points print*, "Enter the coordinates x1,y1,x2,y2,x3,y3" read*, x1,y1,x2,y2,x3,y3 !Calculate d1,d2,d3 a1=(x2-x1)**2+(y2-y1)**2 a2=(x3-x2)**2+(y3-y2)**2 a3=(x3-x1)**2+(y3-y1)**2 d1=sqrt(a1) d2=sqrt(a2) d3=sqrt(a3) !Calculate and print distances if (( d1==d2) .and. ( d1==d3 )) then !If the distances are equal, the shape is a equilateral triangle. print*, "The distances d1 , d2 , d3 have the same value",d1 else if (d1==d2 .and. d3 huge (1) - FI) then exit end if Next = FI + FJ FI = FJ FJ = Next write (unit = *, fmt = *) FJ end do stop end program E07 ! Sum a power series until next term is small enough. program E09 implicit none integer, parameter :: K = selected_real_kind( 12 ) real(kind = K) :: Total, Next_Term real(kind = K), parameter :: TOLERANCE = 1.0e-6_K ! start program E09 Total = 0.0_K Next_Term = 1.0_K do if (Next_Term < TOLERANCE) then exit end if Total = Total + Next_Term Next_Term = 0.5_K * Next_Term end do write (unit = *, fmt = *) " Sum of terms greater than: ", real(TOLERANCE), " is: ", Total stop end program E09