cos() – C函数

C库函数double cos(double x) 返回一个弧度角x的余弦值。

声明

以下是cos()函数的声明。 

double cos(double x)

参数

  • x -- 这是浮点值同比弧度表示的角度。

返回值

这个函数返回x的余弦。

实例

下面的例子显示了cos()函数的用法。

#include<stdio.h>#include<math.h>#define PI 3.14159265int main (){double x, ret, val;
x =60.0;
val =180.0/ PI;
ret = cos( x*val );
printf("The cosine of %lf is %lf degrees
", x, ret);
x =90.0;
val =180.0/ PI;
ret = cos( x*val );
printf("The cosine of %lf is %lf degrees
", x, ret);return(0);}

让我们编译和运行上面的程序,这将产生以下结果:

The cosine of 60.000000 is 0.664171 degrees
The cosine of 90.000000 is -0.299510 degrees

以上是cos() – C函数的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>