Problem Statement:
If the lengths of the sides of a triangle are denoted by a, b,
and c, then area of triangle is given by
area = S(S − a)(S − b)(S − c)
where, S = ( a + b + c ) / 2
and c, then area of triangle is given by
area = S(S − a)(S − b)(S − c)
where, S = ( a + b + c ) / 2
Solution:
//Ahmad Furqan
//P5.i
#include <iostream>
#include <conio.h>
using namespace std;
float triarea(int a, int b, int c)
{
int s;
float area;
s = (a + b + c) / 2;
area = sqrt(s*(s - a)*(s - b)*(s - c));
return area;
}
void main(void)
{
int a, b, c;
cout << "Enter triangle side lengths:" << endl;
cout << "a: ";
cin >> a;
cout << "b: ";
cin >> b;
cout << "c: ";
cin >> c;
cout << "Area of the triangle is: " << triarea(a, b, c);
_getch();
}
sqrt ka error arha h
ReplyDelete