### Cosine Law problem..

Hey guys, i'm new to c++ and the forum so go easy on me..
I was given an assignment to find the missing side length of a triangle

I came up with the following, but keep getting an error about line 22
(error: â2â cannot be used as a function)

#include <iostream>
#include <cmath>

using namespace std;

int main()

{
double a, b, angle, c;

cout << "This program will calculate the missing length of a triangle." <<endl;
cout << "Enter a side length: ";
cin >> a;
cout << "Enter an adjacent side length: ";
cin >> b;
cout << "Now enter the angle (in degrees) between the two previously entered side lengths: ";
cin >> angle;

angle = (angle * (M_PI) / 180);

a = (pow(a, 2));
b = (pow(b, 2));

c = (sqrt(a + b - (2)(a*b)(cos(angle))));

cout << "The missing side length is: " << c << endl;

return 0;

}

Oh Dear, how do I find out which is line 22?
This line

b = (pow(b, 2));
` c = (sqrt(a + b - (2)(a*b)(cos(angle)))); `

C++ doesn't know you mean multiplication when you put ( ) next to each other (as you normally would in math). You need to do
` c = (sqrt(a + b - (2)*(a*b)*(cos(angle)))); `
or else it thinks you are trying to call a function.
Thank you so much!
Topic archived. No new replies allowed.