Home » Program to Find the type of Triangle from the given Coordinates

Program to Find the type of Triangle from the given Coordinates

by Online Tutorials Library

Program to find the type of triangle from the given coordinates

In this article, we will see the programs to find the type of triangle from the given coordinates in different programming languages.

Before jumping directly to the programs, let’s first see a brief description of the triangle.

Triangle

A triangle is a polygon that has three vertices and three edges. The sum of three interior angles of a triangle is 180 degrees. Triangles are of three types that are listed as follows –

  • Equilateral triangle
  • Isosceles triangle
  • Scalene triangle

Let’s see a brief description of types of triangles.

Equilateral triangle

Each angle of an equilateral triangle is of 60 degrees. It has three equal-length sides and three equal angles. It has three lines of symmetry.

Isosceles triangle

An isosceles triangle has one line of symmetry. It has two equal sides and two equal angles.

Scalene triangle

A scalene triangle has no line of symmetry. It has no equal sides and no equal angles.

Now, let’s see the programs to find the type of triangle from the given coordinates.

Programs to find the type of triangle from the given coordinates

The approach that we are using in programs is given as follows –

  • The programs will be made by comparing the given length of sides of the triangle. This classification is simple because if all sides are equivalent triangle will be equilateral, if two sides are equal triangle will be isosceles, if no sides are equal triangle will be scalene.
  • And after comparing the sides, there will be a comparison between angles. Here, we require the square of sides.
  • If the sum of square of the two sides is equal to the square of the third side, the triangle will be a right-angle triangle.
  • If the sum of squares of the smaller sides is less than the square of the largest side, the triangle will be an obtuse angle triangle.
  • If the sum of the squares of the two sides of a triangle is greater than the square of the largest side, the triangle will be an acute angle triangle.

So, basically, we will use the sides of a triangle to find its type and angle.

Program: Write a program to find the type of triangle from the given coordinates in C++.

Output:

Program to find the type of triangle from the given coordinates

Program: Write a program to find the type of triangle from the given coordinates in C#.

Output:

After the execution of the above code, and entering the input, the output will be –

Program to find the type of triangle from the given coordinates

Program: Write a program to find the type of triangle from the given coordinates in Java.

Output

Program to find the type of triangle from the given coordinates

Program: Write a program to find the type of triangle from the given coordinates in JavaScript.

Output

After the execution of above code, the output will be –

Program to find the type of triangle from the given coordinates

Similarly, we have to enter values for two more sides of triangle, after entering the values, the output will be –

Program to find the type of triangle from the given coordinates

So, that’s all about the article. Here, we have discussed the programs to find the type of a triangle from the given coordinates in C++, C#, Java, and JavaScript. Hope you find the article helpful and informative.


Next TopicPrograms List

You may also like