double sin(double angle);其中:angle 是">

c语言sin函数怎么用

来源:这里教程网 时间:2026-02-21 16:49:38 作者:

C 语言中的 sin 函数

sin 函数是什么?

sin 函数是 C 标准库中定义的数学函数,它计算给定角度的正弦值。正弦值是一个介于 -1 和 1 之间的值,表示特定角度在单位圆上的点的 y 坐标。

如何使用 sin 函数?

立即学习“C语言免费学习笔记(深入)”;

sin 函数的语法如下:

<code class="c">double sin(double angle);</code>

其中:

angle
是要计算正弦值的角,以弧度表示。

示例代码

以下是一个使用 sin 函数计算 30 度角正弦值的示例代码:

<code class="c">#include <stdio.h>
#include <math.h>
int main() {
    double angle = 30 * M_PI / 180; // 将角度从度转换为弧度
    double sine = sin(angle);
    printf("30 度的正弦值为: %.2f\n", sine);
    return 0;
}</code>

输出

<code>30 度的正弦值为: 0.50</code>

相关推荐