C语言 <math.h> cos 函数
-
描述
C库函数double cos(double x))返回弧度角x的余弦。 -
声明
以下是cos函数的声明。double cos(double x)
参数- x - 这是浮点值,表示以弧度表示的角度。
-
返回值
此函数返回x的余弦。示例以下示例显示cos函数的用法-
尝试一下#include <stdio.h> #include <math.h> #define PI 3.14159265 int main () { double x, ret, val; x = 60.0; val = PI / 180.0; ret = cos( x*val ); printf("The cosine of %lf is %lf degrees\n", x, ret); x = 90.0; val = PI / 180.0; ret = cos( x*val ); printf("The cosine of %lf is %lf degrees\n", x, ret); return(0); }
让我们编译并运行上面的程序,它将产生以下结果-The cosine of 60.000000 is 0.500000 degrees The cosine of 90.000000 is 0.000000 degrees