c语言求余弦值的程序
作者:野牛程序员:2023-11-13 14:06:38C语言阅读 3049
#include <stdio.h> #include <math.h> int main() { double angle, result; // 输入角度 printf("请输入角度: "); scanf("%lf", &angle); // 将角度转换为弧度 double radians = angle * M_PI / 180.0; // 计算余弦值 result = cos(radians); // 显示结果 printf("角度 %.2lf 的余弦值是 %.4lf\\n", angle, result); return 0; }
使用cos
函数计算弧度对应的余弦值,并将结果存储在result
变量中。
此程序通过获取用户输入的角度值,将其转换为弧度,然后计算对应的余弦值并输出结果。
野牛程序员教少儿编程与信息学奥赛-微信|电话:15892516892

- 上一篇:c++三角函数怎么表示
- 下一篇:c语言求正弦和余弦