9.TRIANGLE SIDES

Image result for c programming
Code:
  #include<stdio.h>
#include<math.h>
int main(){
  int x1,x2,x3,y1,y2,y3;
  float ab,bc,ac;
  printf("Enter the x-coordinate of vertex A\n");
  scanf("%d",&x1);
  printf("Enter the y-coordinate of vertex A\n");
  scanf("%d",&y1);
  printf("Enter the x-coordinate of vertex B\n");
  scanf("%d",&x2);
  printf("Enter the y-coordinate of vertex B\n");
  scanf("%d",&y2);
  printf("Enter the x-coordinate of vertex C\n");
  scanf("%d",&x3);
  printf("Enter the y-coordinate of vertex C\n");
  scanf("%d",&y3);
  ab=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
  bc=sqrt(pow((x3-x2),2)+pow((y3-y2),2));
  ac=sqrt(pow((x1-x3),2)+pow((y1-y3),2));
  printf("Length of side AB is %.1f",ab);
  printf("\nLength of side BC is %.1f",bc);
  printf("\nLength of side AC is %.1f",ac);
  return 0;
}

No comments