Q16 Write a function to compute the distance between two points and use it to develop another function that will compute the area of the triangle whose vertices are A(x1, y1), B(x2, y2), and C(x3, y3). Use these functions to develop a function which returns a value 1 if the point (x, y) lines inside the triangle ABC, otherwise returns a value 0.

Program: 137

Write a function to compute the distance between two points and use it to develop another function that will compute the area of the triangle whose vertices are A(x1, y1), B(x2, y2), and C(x3, y3). Use these functions to develop a function which returns a value 1 if the point (x, y) lines inside the triangle ABC, otherwise returns a value 0.

distance = √(x2-x1)2+(y2-y1)2)

area = √(S(S-a)(S-b)(S-c))
where, S = (a+b+c)/2.

Output:

Enter the values of (x1,y1): 1 2
Enter the values of (x2,y2): 2 4
Enter the values of (x3,y3): 3 2
Enter point values (x,y): 2 3

 Area of triangle: 2.00

Point(2.00, 3.00) lies inside the triangle.

Lokesh Kumar

Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.