Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. double TArea(double, double, double);
  5. int main()
  6. {
  7. double a, b, c, alan;
  8. cout << "Enter the sides of the triangle: ";
  9. cin >> a >> b >> c;
  10. alan = TArea(a, b, c);
  11. cout << "The area of this triangle is "
  12. << alan << endl;
  13. system("Pause");
  14. return 0;
  15. }
  16. double TArea(double a, double b, double c)
  17. {
  18.  
  19. if (a<0. || b<0. || c<0.) return 0.0;
  20. if (a >= b+c) return 0.0;
  21. if (b >= a+c) return 0.0;
  22. if (c >= a+b) return 0.0;
  23. double u, area;
  24. u = 0.5*(a+b+c);
  25. area = sqrt(u*(u-a)*(u-b)*(u-c));
  26. return area;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement