C_C++/C_라이브러리_함수

(C언어) cos, cols: 코사인 계산

고니자니 2023. 2. 2. 10:28
반응형

#cos #cos

 

#include <math.h>
double cos(double x);
long double cosl(long double x;

코사인을 계산합니다.

실수의 코사인 값은 범위가 -1에서 1 사이인 값을 반환합니다.

 

#include <stdio.h>
#include <math.h>
int main()
{
	double x;
	for(x=-1; x<=1; x+=0.1)
		printf("%f\t%f\n", x, cos(x));

	return 0;
}

-1.000000       0.540302
-0.900000       0.621610
-0.800000       0.696707
-0.700000       0.764842
-0.600000       0.825336
-0.500000       0.877583
-0.400000       0.921061
-0.300000       0.955336
-0.200000       0.980067
-0.100000       0.995004
-0.000000       1.000000
0.100000        0.995004
0.200000        0.980067
0.300000        0.955336
0.400000        0.921061
0.500000        0.877583
0.600000        0.825336
0.700000        0.764842
0.800000        0.696707
0.900000        0.621610
1.000000        0.540302

 

 

반응형