fork download
  1. PROGRAM Triangle
  2. REAL :: a, b, c, s, areasq, area
  3. WRITE (*,*) "This program calculates the area of a triangle"
  4. WRITE (*,*) "Type in the lenths of the three sides: "
  5. READ (*,*) a, b, c
  6. WRITE (*, *) "Check: you have input the following lengths: "
  7. WRITE (*, *) a, b, c
  8. s = 0.5 * (a+b+c) !Semiperimeter
  9. areasq = s * (s-a) * (s-b) * (s - c) ! square of area
  10. IF (areasq < 0.0) THEN
  11. WRITE (*,*) "Error, that is not a real triangle"
  12. ELSE
  13. area = SQRT(areasq)
  14. WRITE (*,*) "The area of the triangle is", area
  15. END IF
  16. END PROGRAM Triangle
Runtime error #stdin #stdout 0.01s 2620KB
stdin
5 3 4
stdout
 This program calculates the area of a triangle
 Type in the lenths of the three sides: