Dotcpp  >  编程教程  >  math.h头文件  >  C语言cos()函数:余弦函数

C语言cos()函数:余弦函数

点击打开在线编译器,边学边练

函数名: cos

头文件:<math.h>

函数原型: double cos(double x);

功 能: 余弦函数

参 数: double x  要操作的弧度

返回值: 返回x弧度的余弦值

公 式: 1°=π/180°弧度

注 意:cos() 是已知一个角的弧度值 x,求该角的余弦值 y


程序例:  求60度角的余弦值,并输出结果

#include<math.h>

#include<stdio.h>

#define PI 3.14159265

int main(void){

   double result;

   double x = 60*PI/180;  //将60度角转换为弧度

   result = cos(x);

   printf("The cosine of %lf is %lf\n", x, result);

   return 0;

}

 

运行结果:

The cosine of 1.047198 is 0.500000



本文固定URL:https://www.dotcpp.com/course/476

C语言函数库
assert.h头文件
ctype.h头文件
float.h头文件
io.h头文件
math.h头文件
mem.h头文件
setjmp.h头文件
stdio.h头文件
stdlib.h头文件
sigal.h头文件
string.h头文件
time.h头文件
Dotcpp在线编译      (登录可减少运行等待时间)