CS19002 Programming and Data Structures Laboratory, Section 5

Spring 2007

Assignment 1

Submission site  |  Show solution  |  Hide solution ]

Write a C program that reads the coordinates of the three vertices of a triangle ABC and determines whether the triangle is equilateral or isosceles or neither. In case the triangle is isosceles, your program should also report the two sides that are of equal length.

Submit the output of your program on the following triangles:

   (1,1), (4,-3), (8,0)
   (1,1), (4,3), (8,0)
   (1.1,-2.1), (6.6,6.8), (10.0,-7.6)
   (2,-2), (-4,4), (-2,0)
   (0,0), (10,0), (5,5*sqrt(3))

Sample runs

Point A: 0,0
Point B: 5,0
Point C: 0,-5
The triangle is isosceles with |AB| = |AC|.

Point A: 2,3
Point B: 3,5
Point C: 5,8
The triangle is neither isosceles nor equilateral.

Mathematical challenge (not for submission)

Try to locate a non-trivial triangle for which your program outputs "The triangle is equilateral".

Submission site  |  Show solution  |  Hide solution ]

Back  |  Home