Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- double triangleArea (double a, double b, double c)
- {
- if (a+b>c && a+c>b && b+c>a)
- {
- double s=(a+b+c)/2;
- return std::sqrt(s*(s-a)*(s-b)*(s-c));
- }
- else
- {
- return 0;
- }
- }
- int main()
- {
- int a, b, c;
- std::cout<<"Enter the sides of the triangle: \t";
- std::cin>>a>>b>>c;
- double P=triangleArea (a, b, c);
- if (P==0)
- {
- std::cout<<"There is not a triangle with these sides";
- }
- else
- {
- std::cout<<"Its area is: \t"<<P;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement