fueanta

Area of a triangle from its sides.

Nov 5th, 2016
139
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // cpp program to determine the area of a triangle from its sides..
  2.  
  3. #include "iostream"
  4. using namespace std;
  5.  
  6. int main() {
  7.     int x, y, z;
  8.     cout << "Sides of that triangle : ";
  9.     cin >> x >> y >> z;
  10.     double p;
  11.     if ((x+y) > z && (y+z) > x && (x+z) > y)
  12.         p = (x + y + z) / 2.0;
  13.     else {
  14.         cout << "Invalid Input has given. Try again! \n" << endl;
  15.         main();
  16.     }
  17.     double area = p * (p - x) * (p - y) * (p - z);
  18.     cout << "Area : " << area << endl;
  19.     return 0;
  20. }
RAW Paste Data