😸

[C] sin 関数

に公開

機能

三角関数の正弦(sine)値を求める関数[1]

使用例

0.5 の正弦値を表示する

\n は改行を表す エスケープシーケンス[2]

コード

printf("%f\n", sin(0.5));
全文
#include <stdio.h>
#include <math.h>
void main() {
    printf("%f\n", sin(0.5));
}

実行結果

0.479426

ラジアンを変数に入れて表示する

コード

double theta = 1.0;
printf("%f\n", sin(theta));
全文
#include <stdio.h>
#include <math.h>
void main() {
    double theta = 1.0;
    printf("%f\n", sin(theta));
}

実行結果

0.841471
脚注
  1. 引数にラジアンを指定すると、その角度の正弦(y = \sin\theta)を返す。角度ではなくラジアン単位で指定する点に注意。 ↩︎

  2. 改行やタブなど、画面に表示されない制御文字のこと。 ↩︎

Discussion