C-standard-library-c-function-cos
提供:Dev Guides
Cライブラリ関数-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