cout << '\n' << "Please enter the value of the first side: ";
cin >> dM;
cout << "Please enter the value of the second side: "; cin >> dN;
cout << "Please enter the value of the included angle: "; cin >> dP;
double (*call)(double, double, double) = MissingSide;
dA = MissingSide (dM, dN, dP);
cout << "The value of the missing side is: " << dA << endl;
cout << "Would you like to calculate again (y/n)" << endl;
char cAgain;
cin >> cAgain;
cout << '\n';
if (cAgain == 'y') {
bAgain = false;
} else if (cAgain == 'n') {
bAgain = true;
} else {
cout << "Incorrect Response" << endl;
}
} while (!bAgain);
system("pause");
return 0;
*** This program is meant to do the law of cosines for the obtaining of a missing side, not an angle. All the user has to do is enter the values of the two missing sides and the included angle. It runs through the program successfully; however, when I check the answer, i find that it is way off. Help?
Write a program that just calculates cos(x) for different values of x. See if it gives you the answer you are expecting. If not read the manual for cos(x).
/* cos example */
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main ()
{
double param, result;
param = 60.0;
result = cos (param*PI/180);
printf ("The cosine of %lf degrees is %lf.\n", param, result );
return 0;
}