Source Code for Lab #5
// LAB053.cpp Program to test TriArea function
#include <iostream.h>
#include <math.h>
int main(void)
{
float TriArea(float a, float b, float c);
float a, b, c; // sides of triangle
//*** display instructions here
cout << "Enter side a: ";
cin >> a;
cout << "Enter side b: ";
cin >> b;
cout << "Enter side c: ";
cin >> c;
cout << "Area of Triangle is: " << TriArea(a, b, c) << endl;
return 0;
}
//
// Function to calculate the area of a triangle given 3 sides
// Pre: Sides, a, b, c, form a triangle.
// Post: The function has returned the area of the triangle.
//
float TriArea(float a, float b, float c)
{
float s, // semiperimeter
temp; // square of area of triangle
//*** calculate s
//*** calculate temp = s(s-a)(s-b)(s-c)
//*** change stub return below to calculate and return area
return 0; //*** change return value
}