forked from Rustam-Z/cpp-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08_scalene_triangle.cpp
More file actions
37 lines (32 loc) · 894 Bytes
/
Copy path08_scalene_triangle.cpp
File metadata and controls
37 lines (32 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// C++ program to Calculate Area of Scalene Triangle.
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
cout << "\t\tC++ program to Calculate Area of Scalene Triangle.\n";
float a, b, c, S, Area;
cout << "Please enter the values for the first side of Triangle: ";
cin >> a;
cout << "Please enter the values for the second side of Triangle: ";
cin >> b;
cout << "Please enter the values for the third side of Triangle: ";
cin >> c;
if (a > 0 && b > 0 && c > 0) {
if (c < a + b && a < b + c && b < a + c) {
S = (a + b + c) / 2;
Area = sqrt(S * (S - a) * (S - b) * (S - c));
cout << "The Area of Triangle is " << Area << endl;
return 0;
}
else {
cout << "This triangle is wrong try another values." << endl;
return 0;
}
}
else {
cout << "The sides of Triangle cannot be negative numbers!" << endl;
}
system("pause");
return 0;
}