#include<iostream>
#include<iomanip>
#include<cmath>
usingnamespace std;
int main()
{
int A,B,C,t,theta;
float pi=22/7;
theta=140.0;
t=theta/180.0*pi;
C=sqrt(A^2+B^2-2*A*B*cos(theta));
cout<<C<<endl;
return 0;
}
um havin error massage "test2.cpp:11: error: invalid operands of types ‘double’ and ‘double’ to binary ‘operator^’
" can somebody tell me what's wrong in here.
Ooops I guess that is what I get for learning other programming languages at the same time. If you need a power other than 2 use doubles with the math pow function. http://cplusplus.com/reference/clibrary/cmath/pow/
I intentionally didn't mention pow() because it's so often abused.
Don't use pow if you can [reasonably] avoid it. Even raising things to the 3rd or 4th power you're probably better off multiplying. pow is for tricky stuff like raising to 2.16.