Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ Area of Triangle

    //uisng Heron's Formula
    float first, second, third, semiperimeter, area;

    cout << "Input the first side of the triangle: ";
    cin >> first;
    cout << "Input the first side of the triangle: ";
    cin >> second;
    cout << "Input the third side of the triangle: ";
    cin >> third;

    semiperimeter = (first + second + third)/2;
    area = sqrt (semiperimeter*(semiperimeter-first)*(semiperimeter-second)*(semiperimeter-third));

    cout << "The area of the triangle is " << area << endl;
 
PREVIOUS NEXT
Tagged: #Area #Triangle
ADD COMMENT
Topic
Name
6+5 =