next up previous contents
Next: Solution Up: Control StructureIntrinsics and Previous: Control StructureIntrinsics and

 

The `Triangle Program'

Write a program to accept three (INTEGER) lengths and report back on whether these lengths could define an equilateral, isosoles or scalene triangle (3, 2 or 0 equal length sides) or whether they cannot form a triangle.

Demonstrate that the program works by classifying the following:

  1. (1, 1, 1)
  2. (2, 2, 1)
  3. (1, 1, 0)
  4. (3, 4, 5)
  5. (3, 2, 1)
  6. (1, 2, 4)

[Hint: If three lengths form a triangle then 2 times the longest side must be less than the sum of all three sides. In Fortran 90 terms, the following must be true:

     (2*MAX(side1,side2,side3) < side1+side2+side3)

]

Go back to Notes gif




next up previous contents
Next: Solution Up: Control StructureIntrinsics and Previous: Control StructureIntrinsics and

©University of Liverpool, 1997
Thu May 29 10:11:26 BST 1997
Not for commercial use.