--- In [email protected], Jefferson Mendoza
<[EMAIL PROTECTED]> wrote:
>
> I mean sir, the formula is log(cos(15)
>
> how can i get the answer in negative and decmal form.. for example..
>
> #include<math.h>
> #include<stdio.h>
> int main(void)
>
>
> {
>
> int x;
> int y;
>
>
> x = cos(15);
> y = log10(x);
> printf("%d",y);
>
> }
>
> the error is log10:sing error
> overflow
I think the problem is cos(15). The cos() function argument is an
angle in radians, not degrees. Also, you should be using float
variables, not int. Try this:
/* Convert degrees to radians. */
#define DEG2RAD(deg) ((deg) * M_PI / 180.0)
int main(void)
{
float x, y;
x = cos(DEG2RAD(15));
y = log10(x);
printf("%f\n", y);
return 0;
}
This converts the angle in degrees to the equivalent value in radians,
and the program outputs:
-0.015056