/** * Sample C++ program that computes the area of a triangle * using the Heron's formula. Used to demonstrate debugging * in Visual C++. * * Vladimir Vacic (vladimir AT cs.ucr.edu) * Computer Science and Engineering Department * University of California, Riverside * Apr-12-2005 * Compiler: Visual C++ .NET */ #include #include using namespace std; int main() { float side1, side2, side3, halfcir, area; cout << "Enter the length of one side of the triangle: "; cin >> side1; cout << endl << "Enter the length of another side of the triangle: "; cin >> side2; cout << endl << "Enter the length of the third side of the triangle: "; cin >> side3; halfcir = (side1 + side2 + side3) / 2; area = sqrt(halfcir * (halfcir-side1) * (halfcir-side2) * (halfcir-side3)); cout << endl << "The area of the triangle is: " << area << endl; return 0; }