fork(1) download
  1. //Calculation of sides and perimeter of triangle
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. int main(void){
  6. double xA, yA, xB, yB, xC, yC, AB, BC, AC, p;
  7. printf("Coordinates of point A:\n");
  8. scanf("%lf %lf", &xA, &yA);
  9. printf("Coordinates of point B:\n");
  10. scanf("%lf %lf", &xB, &yB);
  11. printf("Coordinates of point C:\n");
  12. scanf("%lf %lf", &xC, &yC);
  13. AB = sqrt((xA - xB) * (xA - xB) + (yA - yB) * (yA - yB));
  14. BC = sqrt((xB - xC) * (xB - xC) + (yB - yC) * (yB - yC));
  15. AC = sqrt((xA - xC) * (xA - xC) + (yA - yC) * (yA - yC));
  16. p = AB + BC + AC;
  17. printf("AB=%8lg\n", AB);
  18. printf("BC=%8lg\n", BC);
  19. printf("AC=%8lg\n", AC);
  20. printf("p =%8lg\n", p);
  21. return 0;
  22. }
Success #stdin #stdout 0s 2300KB
stdin
0 0
3 0
0 3
stdout
Coordinates of point A:
Coordinates of point B:
Coordinates of point C:
AB=       3
BC= 4.24264
AC=       3
p = 10.2426