Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double TArea(double, double, double);
- int main()
- {
- double a, b, c, alan;
- cout << "Enter the sides of the triangle: ";
- cin >> a >> b >> c;
- alan = TArea(a, b, c);
- cout << "The area of this triangle is "
- << alan << endl;
- system("Pause");
- return 0;
- }
- double TArea(double a, double b, double c)
- {
- if (a<0. || b<0. || c<0.) return 0.0;
- if (a >= b+c) return 0.0;
- if (b >= a+c) return 0.0;
- if (c >= a+b) return 0.0;
- double u, area;
- u = 0.5*(a+b+c);
- area = sqrt(u*(u-a)*(u-b)*(u-c));
- return area;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement