## Triangle sides in C Programming Language

In this C programming tutorial, we will learn how to find the Sides of Triangle in  C programming language.

## C PROGRAM TO FIND THE SIDES OF A TRIANGLE.

```#include<stdio.h>
#include<math.h>
float distance(int x1,int x2,int y1,int y2)
{
float distance;
distance=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
return distance;
}
int main()

{
int xA,xB,xC,yA,yB,yC; //variable declaration
float a1,a2,a3;
printf("Please enter the x-coordinate of vertex A of the triangle\n");
scanf("%d",&xA);
printf("Please enter the y-coordinate of vertex A of the triangle\n");
scanf("%d",&yA);
printf("Please enter the x-coordinate of vertex B of the triangle\n");
scanf("%d",&xB);
printf("Please enter the y-coordinate of vertex B of the triangle\n");
scanf("%d",&yB);
printf("Please enter the x-coordinate of vertex C of the triangle\n");
scanf("%d",&xC);
printf("Please enter the y-coordinate of vertex C of the triangle\n");
scanf("%d",&yC);
a1=distance(xA,xB,yA,yB);
a2=distance(xB,xC,yB,yC);
a3=distance(xA,xC,yA,yC);
printf("Length of side AB is %.1f\n",a1);
printf("Length of side BC is %.1f\n",a2);
printf("Length of side AC is %.1f\n",a3);
return 0;
}```

In the above C program, we learnt how to find the Sides of Triangle in C programming language.

### 1 Comments

• […] To find the Midpoint Coordinate of the line, you can take help of the below C Program. […]