Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Heron’s formula for the area, A, of a triangle with sides of length a, b, and c

ID: 3847793 • Letter: H

Question

Heron’s formula for the area, A, of a triangle with sides of length a, b, and c is A = [s(s - a)(s - b)(s - c)] where s = (a +b +c) / 2. Write, test, and execute a C++ program that accepts the values of a, b, and c as parameters from a calling function, and then calculates the values of s and [s(s - a)(s - b)(s - c)]. If this quantity is positive, the function calculates A. If the quantity is negative, a, b, and c do not form a triangle, and the function should set A = -1. The value of A should be returned by the function. RETURN A SINGLE VALUE! BE SURE TO USE ALL GLOBAL VARIABLES!

** Here is what I have done, just need some help debugging and tweaking. The variables should be a, b, and c as well. I included the error message:

8 #include Kiostream> #include kiomanip include Kcmath 10 11 using namespace std 12 13 double heron Formula (double, double, double); double first Side secondside, thirdside s, 1, area 14 15 16 int main() 17 cout "Please Input The Length of The Three Sides In 18 cin firstSide secondside thirdside 19 20 Cout "VnThe Area Is heron Formula (firstside secondside, thirds ide) endl 21 cout The Perimeter Is first Side second Side thirdSide endl endl 22 23 system ("pause"); 24 25 26 return 0 27 28 29 30 double heron Formula (double sideone, double sideTwo, double sideThree); 31 s (sideone side Two sideThree) 2; 32 33 s1 sqrt(s*(s sideone) (s sideTwo)*(s sideThree)); 34 35 if (s1 e) 36 area sqrt(s1) 37 else 38 39 area -1; 40 41 return area 42 43 Error List Entire Solution 1 Error 40 warnings 0 0 Messages xr Build IntelliSense Search Error List Code Description Project File Line Suppression State missing function header c2447 (old-style formal ist?) Error List output

Explanation / Answer

Your program is perfectly fine. Just one small mistake. Please remove the semi-colon at the end of fuction name heron() on line 31. That is causing the error. If the semicolon is removed, program should work perfectly fine.

Also I would use the condition s > 0 and not greater than equal to. If s is zero , area is 0 and it would not form a triangle. So making condition s>0 would be recommended.

Please rate the answer if it helped. Thank you very much.