Ok guys...so I have 2 versions of this perimeter program where I'm trying to find I believe the value of c(squared) There 1st Version looks like this.
Given the code snippet of a calling function ->
Code the calcPerimeter () function
The following formulas may be helpful.
c2 = a2 + b2;
area = .5 * (a * b)
Remember: your function should use the two input parameters sideA and sideB to calculate and return the perimeter.
Sample Run
Side A is: 3.000000
Size B is: 4.000000
Size C is: 5.000000
The perimeter is: 12.000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
int main()
{
// prototype (size A, size B)
double calcPerimeter ( double, double );
// variable
double sideA = 3;
double sideB = 4;
double sideC;
double perimeter;
// call: calcPerimeter & then calc sideC
perimeter = calcPerimeter(sideA, sideB);
sideC = sqrt(perimeter);
// output
cout << fixed << showpoint << setprecision(6);
cout << "Side A is: " << sideA << endl;
cout << "Size B is: " << sideB << endl;
cout << "Size C is: " << sideC << endl;
cout << "The perimeter is: " << perimeter;
cout << endl;
return 0;
}
|
I know my function is going to look like this for this version...
1 2 3 4
|
double calcPerimeter()
{
}
|
I cant really figure out the body on this though...
The second version of the program looks as follows...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
Given the code snippet of a calling function ->
Code the calcSideC () function
The following formulas may be helpful.
c2 = a2 + b2;
area = .5 * (a * b)
Remember: your function should use the two input parameters sideA and sideB to calculate and return sideC.
Sample Run
Side A is: 3.000000
Size B is: 4.000000
Size C is: 5.000000
The perimeter is: 12.000000
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
int main()
{
// prototype (size A, size B)
double calcSideC ( double, double );
// variable
double sideA = 3;
double sideB = 4;
double sideC;
double perimeter;
// calc sideC & perimeter
sideC = calcSideC(sideA, sideB);
perimeter = sideA + sideB + sideC;
// output
cout << fixed << showpoint << setprecision(6);
cout << "Side A is: " << sideA << endl;
cout << "Size B is: " << sideB << endl;
cout << "Size C is: " << sideC << endl;
cout << "The perimeter is: " << perimeter;
cout << endl;
return 0;
}
|
So I guess I just really dont see how these two differ from another..besides the fact that your solving for perimeter in one and side C in the other but the code pretty much looks identical...and again I have my function beginning here.
1 2 3 4
|
double calcSideC()
{
}
|
Any hints would be appreciated thank you...